Subject: Re: bug#9079: integer overflow etc. issues (e.g., image crashes Emacs)

From: Paul Eggert <[email-masked]>
Date: Thu, 14 Jul 2011 09:15:36 -0700

On 07/14/11 01:22, Andreas Schwab wrote:
>> -#define __malloc_size_t int
>> +#define __malloc_size_t size_t
> 
> There is no point in using that name any more.

Thanks, I can easily install the following further patch as well.
There are similar usages in gmalloc.c but that's verging even more
into code cleanup and at this point I assume we should be focusing
on the bug fixes.

* alloc.c (__malloc_size_t): Remove.
All uses replaced by size_t.  See Andreas Schwab's note
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9079#8>.
=== modified file 'src/alloc.c'
--- src/alloc.c	2011-07-13 03:45:56 +0000
+++ src/alloc.c	2011-07-14 16:03:17 +0000
@@ -68,10 +68,6 @@
 #ifdef DOUG_LEA_MALLOC

 #include <malloc.h>
-/* malloc.h #defines this as size_t, at least in glibc2.  */
-#ifndef __malloc_size_t
-#define __malloc_size_t size_t
-#endif

 /* Specify maximum number of areas to mmap.  It would be nice to use a
    value that explicitly means "no limit".  */
@@ -82,9 +78,8 @@

 /* The following come from gmalloc.c.  */

-#define	__malloc_size_t		size_t
-extern __malloc_size_t _bytes_used;
-extern __malloc_size_t __malloc_extra_blocks;
+extern size_t _bytes_used;
+extern size_t __malloc_extra_blocks;

 #endif /* not DOUG_LEA_MALLOC */

@@ -1111,11 +1106,11 @@
 #  define BYTES_USED _bytes_used
 #endif

-static __malloc_size_t bytes_used_when_reconsidered;
+static size_t bytes_used_when_reconsidered;

 /* Value of _bytes_used, when spare_memory was freed.  */

-static __malloc_size_t bytes_used_when_full;
+static size_t bytes_used_when_full;

 /* This function is used as the hook for free to call.  */