Re: Fixing a long standing bug in view.c
- From: Jakub Jelinek <jakub redhat com>
- To: Pavel Roskin <proski gnu org>
- Cc: Philipp Thomas <pthomas suse de>, mc-devel gnome org
- Subject: Re: Fixing a long standing bug in view.c
- Date: Wed, 26 Feb 2003 20:43:15 +0100
On Wed, Feb 26, 2003 at 01:08:34PM -0500, Pavel Roskin wrote:
> Hello, Philipp!
>
> > view.c erroneously assumes it can easily malloc a file if mmap failed and
> > passes view->s.st_size to g_malloc. But if largefile support has been enabled,
> > view->s.st_size is a 64 bit value and thus possibly exceeds the limit of
> > gulong which g_malloc takes for size. This patch fixes it.
>
> 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);
Shouldn't that be g_try_malloc? mc died on me today when trying to view
a 2.8GB file, I assume because mmap failed and
g_malloc kills the application if it fails...
Jakub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]