Fixing a long standing bug in view.c

Philipp Thomas pthomas at suse.de
Wed Feb 26 19:15:55 UTC 2003


* Pavel Roskin (proski at gnu.org) [20030226 19:08]:

> I've applied a much simple patch for this:
> 
> /* Make sure view->s.st_size is not truncated when passed to g_malloc */
> if ((gulong) view->s.st_size == view->s.st_size)
>     view->data = (unsigned char *) g_malloc ((gulong) view->s.st_size);
> 

Yes, this sure is much simpler :) Just don't forget to view->data=NULL in
the else branch as otherwise you'll get a segfault here:

       if (view->data != NULL)
            g_free (view->data);

> Thank you for reporting the problem!

You're welcome. I had to fix this anyway to get a working mc package for
the next version of SuSE Linux, and a fix accepted upstream is one fix less
I have to maintain :)

Philipp

-- 
Philipp Thomas <pthomas at suse.de>
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany



More information about the mc-devel mailing list