* 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.
This commit is contained in:
Ralf Wildenhues 2004-10-01 10:24:18 +00:00 committed by Gary V. Vaughan
parent 921d06b537
commit 9bc5390549
3 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,9 @@
2004-10-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* 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.
* libltdl/slist.c (slist_foreach): result was declared as
inner variable, shadowing the actually returned value.

View File

@ -82,7 +82,12 @@ lt__realloc (void *mem, size_t n)
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 *

View File

@ -1992,8 +1992,13 @@ lt_dlcaller_register (const char *id_string, lt_dlhandle_interface *iface)
{
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;
}