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

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Organization Red Hat
Message-ID <[email protected]>
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   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.