Bug 690594 - memleak in pdfdraw
Summary: memleak in pdfdraw
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: Macintosh MacOS X
: P4 normal
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-03 00:40 UTC by Krzysztof Kowalczyk
Modified: 2009-12-02 09:51 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Kowalczyk 2009-07-03 00:40:18 UTC
pdfdraw doesn't close the xref, causing memleaks. It makes finding real memleaks
with valgrind harder.

Index: apps/pdfdraw.c
===================================================================
--- apps/pdfdraw.c	(revision 1201)
+++ apps/pdfdraw.c	(working copy)
@@ -80,6 +80,26 @@
 	fz_keepobj(xref->info);
 }
 
+void closexref(void)
+{
+	if (pagetree)
+	{
+		pdf_droppagetree(pagetree);
+		pagetree = nil;
+	}
+
+	if (xref)
+	{
+		if (xref->store)
+		{
+			pdf_dropstore(xref->store);
+			xref->store = nil;
+		}
+		pdf_closexref(xref);
+		xref = nil;
+	}
+}
+
 /*
  */
 
@@ -474,5 +494,6 @@
 	drawpages("1-");
 
     fz_droprenderer(drawgc);
+    closexref();
 }