[gs-bugs] [Bug 691484] Valgrind shows use of uninitialised memory in clist code

bugzilla-daemon at ghostscript.com bugzilla-daemon at ghostscript.com
Wed Jul 21 18:44:49 UTC 2010


http://bugs.ghostscript.com/show_bug.cgi?id=691484

--- Comment #2 from Robin Watts <robin.watts at artifex.com> 2010-07-21 18:44:47 UTC ---
I am regenerating the valgrind log now and will attach it in a moment.

The errors fall into 2 categories.

1) All but the last error in the file appear to be to do with encoding a bitmap
from a cached character where the buffer appears to have uninitialised data in
it.

I have a workaround that stops these warnings:

base/gdevprn.c: line 122 onwards
     for ( space = space_params->BufferSpace; ; ) {
         base = (reallocate ?
                 (byte *)gs_resize_object(buffer_memory, *the_memory, space,
                                          "cmd list buffer") :
                 gs_alloc_bytes(buffer_memory, space,
                                "cmd list buffer"));
         if (base != 0)
+        {
+            if (!reallocate)
+                memset(base, 0, space); /* RJW */
+            break;
+        }
         if (bufferSpace_is_exact || (space >>= 1) < PRN_MIN_BUFFER_SPACE)
             break;
     }

Clearly this is not the correct solution (for no other reason but that it
leaves the (extra) memory uncleared in the reallocate case), but it suffices to
stop the warnings in this case.

2) The second case is to do with strange results within an ftell call. I have a
similar workaround for that:

gxclist.c: line 728

 int    /* ret 0 all-ok, -ve error code, or +1 ok w/low-mem warning */
 clist_end_page(gx_device_clist_writer * cldev)
 {
     int code = cmd_write_buffer(cldev, cmd_opv_end_page);
     cmd_block cb;
     int ecode = 0;

+    memset(&cb, 0, sizeof(cb)); /* RJW */
     if (code >= 0) {
         /*
          * Write the terminating entry in the block file.
          * Note that because of copypage, there may be many such entries.
          */

It remains to be seen if these solve the original customers problem, but even
if they do, clearly we'd like a better solution.

-- 
Configure bugmail: http://bugs.ghostscript.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the gs-bugs mailing list