bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] avoid malloc(0) for AIX


From: Eric Blake
Subject: Re: [PATCH] avoid malloc(0) for AIX
Date: Mon, 24 Oct 2011 12:20:58 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.4 Thunderbird/3.1.15

On 10/24/2011 12:11 PM, Fabian Groffen wrote:
On AIX, malloc(0) segfaults, hence avoid calling malloc(0).

--- sed-4.2.1/lib/regex_internal.c
+++ sed-4.2.1/lib/regex_internal.c
@@ -883,6 +883,9 @@
       re_node_set *set;
       int size;
  {
+  if ( size == 0 )
+    return REG_NOERROR;
+

Thanks for the patch. However, this would be better discussed on the sed list (added in cc). Furthermore, it would be better to fix this by using the gnulib 'malloc' module, which guarantees GNU behavior of a sane malloc(0) even on AIX, rather than auditing the sed source code for other possible instances of this problem. That is, I think the better patch is:

diff --git i/autoboot.conf w/autoboot.conf
index 436bace..3cd3433 100644
--- i/autoboot.conf
+++ w/autoboot.conf
@@ -1,6 +1,6 @@
 # Bootstrap configuration.

-# Copyright (C) 2006-2008 Free Software Foundation, Inc.
+# Copyright (C) 2006-2008, 2011 Free Software Foundation, Inc.

 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,7 +19,8 @@
 # gnulib modules used by this package.
 gnulib_modules="
     acl alloca btowc c-ctype extensions fwriting getline getopt gettext-h
- localcharset mbrlen mbrtowc mbsinit memchr mkostemp obstack pathmax regex
+    localcharset malloc mbrlen mbrtowc mbsinit memchr mkostemp obstack
+    pathmax regex
     rename selinux-h stdbool stat-macros ssize_t strerror strverscmp
     unlocked-io verify version-etc-fsf wcrtomb wctob"



--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]