diff options
| author | Michael Forney <mforney@mforney.org> | 2021-10-03 02:22:09 -0700 | 
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2021-10-03 02:22:09 -0700 | 
| commit | 6764a38d863103f6ca66bb05fbbe2be2225f973e (patch) | |
| tree | 3da51ff6892069ee46f2ffacfd3f4903b1f9adfe | |
| parent | ac369afb858c399ba05638eb115ad69d58f42b95 (diff) | |
| download | cproc-6764a38d863103f6ca66bb05fbbe2be2225f973e.tar.xz | |
util: Don't error on NULL from malloc if requested size was 0
It is implementation-defined whether malloc returns NULL or some
pointer when the size is 0, so we don't want to error out if the
implementation chose NULL.
| -rw-r--r-- | util.c | 4 | 
1 files changed, 2 insertions, 2 deletions
| @@ -58,7 +58,7 @@ void *  xreallocarray(void *buf, size_t n, size_t m)  {  	buf = reallocarray(buf, n, m); -	if (!buf) +	if (!buf && n && m)  		fatal("reallocarray:");  	return buf; @@ -70,7 +70,7 @@ xmalloc(size_t len)  	void *buf;  	buf = malloc(len); -	if (!buf) +	if (!buf && len)  		fatal("malloc:");  	return buf; | 
