libtool-patches
[Top][All Lists]
Advanced

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

FYI: report malloc failures in lt__memdup and lt_dlcaller_register [libt


From: Gary V. Vaughan
Subject: FYI: report malloc failures in lt__memdup and lt_dlcaller_register [libtool--devo--1.0--patch-220]
Date: Fri, 1 Oct 2004 11:25:44 +0100 (BST)
User-agent: mailnotify/0.3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Applied to HEAD.

  * looking for address@hidden/libtool--devo--1.0--patch-219 to compare with
  * comparing to address@hidden/libtool--devo--1.0--patch-219
  M  ChangeLog
  M  libltdl/ltdl.c
  M  libltdl/lt__alloc.c
  
  * modified files
  
  Index: Changelog
  from  Ralf Wildenhues  <address@hidden>
        * libltdl/lt__alloc.c (lt__memdup): Allocation can fail, so we
        need to guard against null pointer dereference here.
        * libltdl/ltdl.c (lt_dlcaller_register): Ditto.
  
  --- orig/libltdl/lt__alloc.c
  +++ mod/libltdl/lt__alloc.c
  @@ -82,7 +82,12 @@
   void *
   lt__memdup (void const *mem, size_t n)
   {
  -  return memcpy (lt__malloc (n), mem, n);
  +  void *newmem;
  +
  +  if ((newmem = lt__malloc (n)))
  +    return memcpy (newmem, mem, n);
  +
  +  return 0;
   }
   
   char *
  
  
  --- orig/libltdl/ltdl.c
  +++ mod/libltdl/ltdl.c
  @@ -1992,8 +1992,13 @@
   {
     lt__caller_id *caller_id = lt__malloc (sizeof *caller_id);
   
  -  caller_id->id_string = lt__strdup (id_string);
  -  caller_id->iface = iface;
  +  /* If lt__malloc fails, it will LT__SETERROR (NO_MEMORY), which
  +     can then be detected with lt_dlerror() if we return 0.  */
  +  if (caller_id)
  +    {
  +      caller_id->id_string = lt__strdup (id_string);
  +      caller_id->iface = iface;
  +    }
   
     return (lt_dlcaller_id) caller_id;
   }
  
  
  
- -- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook
_________________________________________________________
This patch notification generated by tlaapply version 0.6
http://tkd.kicks-ass.net/arch/address@hidden/cvs-utils--tla--1.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFBXTCnFRMICSmD1gYRAmU7AJ9BDEou6Zl5Vhn8vVCOcdcjkgIwzwCeNm/r
dUotKmOi8ZftZrwdmJely8I=
=JgxM
-----END PGP SIGNATURE-----




reply via email to

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