check memory allocation for calloc, die on failure

This commit is contained in:
Hiltjo Posthuma 2016-08-12 13:09:36 +02:00 committed by Markus Teich
parent cd307e3ba0
commit 8185d5eacb

2
sent.c
View File

@ -210,7 +210,7 @@ ffload(Slide *s)
if (memcmp("farbfeld", hdr, 8)) if (memcmp("farbfeld", hdr, 8))
die("sent: Filtered file '%s' has no valid farbfeld header", filename); die("sent: Filtered file '%s' has no valid farbfeld header", filename);
s->img = calloc(1, sizeof(Image)); s->img = ecalloc(1, sizeof(Image));
s->img->bufwidth = ntohl(*(uint32_t *)&hdr[8]); s->img->bufwidth = ntohl(*(uint32_t *)&hdr[8]);
s->img->bufheight = ntohl(*(uint32_t *)&hdr[12]); s->img->bufheight = ntohl(*(uint32_t *)&hdr[12]);