commit 081c9ebae45ce57b874f18b64e3399f92e456442
parent d5b907c1637d152050fb7e7e8e4664b342957a74
Author: Sebastian <sebastian@sebsite.pw>
Date: Sun, 5 Jun 2022 00:27:03 -0400
check: handle open_memstream error
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -1,4 +1,5 @@
#include <assert.h>
+#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
@@ -46,6 +47,11 @@ gen_typename(const struct type *type)
size_t sz = 0;
char *ptr = NULL;
FILE *f = open_memstream(&ptr, &sz);
+ if (f == NULL) {
+ fprintf(stderr, "Unable to open memstream: %s",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
emit_type(type, f);
fclose(f);
return ptr;