sys-file-reader: Fix memory leak.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 20 Aug 2012 06:59:47 +0000 (23:59 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 20 Aug 2012 06:59:47 +0000 (23:59 -0700)
The C standards say that the compiler is allowed to optimize away
changes to local variables within a function between a call to
setjmp() and a later call to longjmp(), unless the local variables
are volatile-qualified.

The 'dict' local variable in sfm_open_reader() fits this
description but wasn't volatile-qualified.  GCC in fact optimized
out the changes on my system, and this commit fixes that.

src/data/sys-file-reader.c

index e9f63fa0ed68a99ab0d9088663c10449bbd63b66..e6fb4c454b9f051035f44efa21c7ea075d5b4236 100644 (file)
@@ -339,7 +339,7 @@ sfm_open_reader (struct file_handle *fh, const char *volatile encoding,
 
   struct sfm_extension_record *extensions[32];
 
-  struct dictionary *dict = NULL;
+  struct dictionary *volatile dict = NULL;
   size_t i;
 
   /* Create and initialize reader. */