From bf52d9e321b5709adda59e9cd001d51b8d7e801f Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 5 Feb 2023 14:38:31 +0100 Subject: [PATCH] fix: Handle malloc errors properly in pack.c --- examples/pack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/pack.c b/examples/pack.c index c35aad6..19415be 100644 --- a/examples/pack.c +++ b/examples/pack.c @@ -44,6 +44,12 @@ int main(int argc, char** argv) fseek(fp, 0, SEEK_SET); char* buf = malloc(length); + if (!buf) + { + perror("malloc"); + exit_status = 1; + break; + } fread(buf, 1, length, fp); if (ferror(fp)) {