utils: die when trying to allocate zero bytes

This shouldn't occur, so go down when it does.
This commit is contained in:
Benno Schulenberg 2019-10-13 17:41:24 +02:00
parent 3c2eb96243
commit ec9fc5d320

View File

@ -294,7 +294,10 @@ void *nmalloc(size_t howmuch)
{
void *r = malloc(howmuch);
if (r == NULL && howmuch != 0)
if (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
die(_("Nano is out of memory!\n"));
return r;
@ -306,7 +309,10 @@ void *nrealloc(void *ptr, size_t howmuch)
{
void *r = realloc(ptr, howmuch);
if (r == NULL && howmuch != 0)
if (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
die(_("Nano is out of memory!\n"));
return r;