projects
/
paraslash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e373f7d
)
para_malloc(), para_realloc(): Check for zero size allocations.
author
Andre Noll
<maan@systemlinux.org>
Mon, 6 Aug 2007 18:45:19 +0000
(20:45 +0200)
committer
Andre Noll
<maan@systemlinux.org>
Mon, 6 Aug 2007 18:45:19 +0000
(20:45 +0200)
para.h
patch
|
blob
|
history
string.c
patch
|
blob
|
history
diff --git
a/para.h
b/para.h
index 7b0ca09c6c0b5f84c7ddab93eb92912e83245a44..a4753d4b5f5afa4eedc9a982f15f33c2f175626d 100644
(file)
--- a/
para.h
+++ b/
para.h
@@
-24,6
+24,7
@@
#include <sys/socket.h>
#include <sys/un.h> /* needed by create_pf_socket */
#include <string.h>
+#include <assert.h>
#include "gcc-compat.h"
/** used in various contexts */
diff --git
a/string.c
b/string.c
index 598a12f510ecef9cefe13811a848d89cfb90d9a8..8b9f1633d95be658c7a6ecc40f291a0e033943bd 100644
(file)
--- a/
string.c
+++ b/
string.c
@@
-36,6
+36,7
@@
__must_check __malloc void *para_realloc(void *p, size_t size)
* No need to check for NULL pointers: If p is NULL, the call
* to realloc is equivalent to malloc(size)
*/
+ assert(size);
if (!(p = realloc(p, size))) {
PARA_EMERG_LOG("realloc failed (size = %zu), aborting\n",
size);
@@
-58,6
+59,7
@@
__must_check __malloc void *para_realloc(void *p, size_t size)
*/
__must_check __malloc void *para_malloc(size_t size)
{
+ assert(size);
void *p = malloc(size);
if (!p) {