Bug 64680

Summary: pollution of global namespace with internal classes
Product: poppler Reporter: duelli
Component: generalAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: patch (wrapping classes in anonymous namespace)

Description duelli 2013-05-16 17:48:17 UTC
In fofi/FoFiIdentifier.cc there are several internal classes MemReader, FileReader etc.
These are in the global namespace.

Incidentally, in our code there is a class FileReader, too.
It also has a constructor FileReaader(FILE*). Guess which code gets executed in FoFiIdentifier.cc ... the wrong one.
(Yes, FileReader is a rather dangerous name, and no, my FileReader is in the global namespace as well....)
This leads to a crash when opening a pdf containing fonts that need to be
looked up.

Trivial solution: wrap the internal classes with an anonymous namespace.
Or with namespace poppler. As the class is internal to this file, this won't cause problems.

Another good idea might be to introduce symbol (in)visiblity...

Best regards
and thank you for a really helpful library.
Comment 1 Albert Astals Cid 2013-06-01 16:48:27 UTC
Any chance you would send a patch?
Comment 2 duelli 2013-06-09 12:27:36 UTC
Created attachment 80563 [details] [review]
patch (wrapping classes in anonymous namespace)

just wraps the internal classes in namespace { ... }.
(Sorry for the delay, I was offline in holiday.)
Comment 3 Albert Astals Cid 2013-06-09 21:35:30 UTC
Will be in poppler 0.24.0

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.