Bug 54702

Summary: Memory leak in CharCodeToUnicode
Product: poppler Reporter: Albert Astals Cid <aacid>
Component: generalAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: free local allocated utf16 pointer

Description Albert Astals Cid 2012-09-09 20:38:48 UTC
Happens at least with 68.pdf.asan.7.1030

==32010== 8 bytes in 1 blocks are definitely lost in loss record 45 of 388
==32010==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==32010==    by 0x51B31D6: gmalloc(unsigned long, bool) (gmem.cc:120)
==32010==    by 0x51B33FA: gmallocn(int, int, bool) (gmem.cc:212)
==32010==    by 0x51B341E: gmallocn (gmem.cc:216)
==32010==    by 0x51FB351: CharCodeToUnicode::addMapping(unsigned int, char*, int, int) (CharCodeToUnicode.cc:457)
==32010==    by 0x51FAB21: CharCodeToUnicode::parseCMap1(int (*)(void*), void*, int) (CharCodeToUnicode.cc:346)
==32010==    by 0x51FA750: CharCodeToUnicode::mergeCMap(GooString*, int) (CharCodeToUnicode.cc:292)
==32010==    by 0x5230C11: GfxFont::readToUnicodeCMap(Dict*, int, CharCodeToUnicode*) (GfxFont.cc:602)
==32010==    by 0x523359C: Gfx8BitFont::Gfx8BitFont(XRef*, char const*, Ref, GooString*, GfxFontType, Ref, Dict*) (GfxFont.cc:1302)
==32010==    by 0x522F67C: GfxFont::makeFont(XRef*, char const*, Ref, Dict*) (GfxFont.cc:223)
==32010==    by 0x5237912: GfxFontDict::GfxFontDict(XRef*, Ref*, Dict*) (GfxFont.cc:2498)
==32010==    by 0x5213ACC: GfxResources::GfxResources(XRef*, Dict*, GfxResources*) (Gfx.cc:342)

Needs some investigation
Comment 1 Thomas Freitag 2012-09-10 10:19:20 UTC
Created attachment 66919 [details] [review]
free local allocated utf16 pointer

Seems to come with the new UTF16toUCS4. The patch is not regtested by me, because it is obviously that the locally allocated utf16 pointer is never freed.
Comment 2 Albert Astals Cid 2012-09-10 22:40:05 UTC
Oh sorry, this leak is in poppler-0.20 (Where your patch doesn't really apply)
Comment 3 Thomas Freitag 2012-10-20 08:01:49 UTC
(In reply to comment #2)
> Oh sorry, this leak is in poppler-0.20 (Where your patch doesn't really
> apply)

Do I miss something? The leak is also in git master, where I just applied the patch without any changes successfully!
Comment 4 Albert Astals Cid 2012-11-02 22:06:47 UTC
Pushed!

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.