Bug 6187 - mem leak in poppler_page_get_text
Summary: mem leak in poppler_page_get_text
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: glib frontend (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-09 07:46 UTC by Christian Persch (GNOME)
Modified: 2006-03-20 20:26 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
fix leak (1.06 KB, patch)
2006-03-09 07:47 UTC, Christian Persch (GNOME)
Details | Splinter Review

Description Christian Persch (GNOME) 2006-03-09 07:46:49 UTC
==16259== 32 (16 direct, 16 indirect) bytes in 2 blocks are definitely lost in
loss record 93 of 305
==16259==    at 0x401B7F3: operator new(unsigned) (vg_replace_malloc.c:164)
==16259==    by 0x42C6B1F: poppler_page_get_text (poppler-page.cc:633)
==16259==    by 0x8097742: pdf_document_get_text(_EvDocument*, int,
EvRectangle*) (ev-poppler.cc:538)
==16259==    by 0x808BE63: ev_document_get_text (ev-document.c:183)
==16259==    by 0x806F81C: get_selected_text (ev-view.c:3812)
==16259==    by 0x806F97D: ev_view_primary_get_cb (ev-view.c:3854)

Code:

poppler_page_get_text (PopplerPage      *page,
                       PopplerRectangle *selection)
{
[...]
  GooString *sel_text = new GooString;
[...]
  sel_text = text_dev->getSelectionText (&pdf_selection);
  result = g_strdup (sel_text->getCString ());
  delete sel_text;

  return result;
}

text_dev->getSelectionText returns a new'd GooString too, so this leaks.
Comment 1 Christian Persch (GNOME) 2006-03-09 07:47:37 UTC
Created attachment 4865 [details] [review]
fix leak
Comment 2 Jeff Muizelaar 2006-03-21 06:05:56 UTC
The first hunk of the patch looks good. The second hunk seems unrelated. What 
is it about?
Comment 3 Christian Persch (GNOME) 2006-03-21 07:18:27 UTC
(In reply to comment #2)
> The first hunk of the patch looks good. The second hunk seems unrelated. What 
> is it about?

Oh sorry I forgot to remove it, it's unrelated to this bug. It saves a strdup
(g_value_set_string strdups, but since we're going to call g_free, we can just
transfer the string to the GValue with g_value_take_string).
Comment 4 Jeff Muizelaar 2006-03-21 15:26:18 UTC
patch committed.


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.