Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
When asked to malloc zero bytes, malloc one byte instead. This ensures
Browse files Browse the repository at this point in the history
that we get a unique pointer rather than NULL (which ANSI C otherwise permits).
Problem pointed out by Mike Protts.

[originally from svn r6308]
  • Loading branch information
bjh21 committed Sep 13, 2005
1 parent 059e409 commit f2d8fd9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void *safemalloc(size_t n, size_t size)
p = NULL;
} else {
size *= n;
if (size == 0) size = 1;
#ifdef MINEFIELD
p = minefield_c_malloc(size);
#else
Expand Down

0 comments on commit f2d8fd9

Please sign in to comment.