shithub: rgbds

Download patch

ref: f5ac2689895f48509211ed99fcdcf2f069d2d7de
parent: d51ab3520328fe7bd82f37da276180c3d7d4059d
author: ISSOtm <[email protected]>
date: Sun Jun 12 12:36:35 EDT 2022

Fix unchecked realloc in `makeUnknown`

--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -39,6 +39,8 @@
 	int size = snprintf(_expr->reason, 128, __VA_ARGS__); \
 	if (size >= 128) { /* If this wasn't enough, try again */ \
 		_expr->reason = realloc(_expr->reason, size + 1); \
+		if (!_expr->reason) \
+			fatalerror("Can't allocate err string: %s\n", strerror(errno)); \
 		sprintf(_expr->reason, __VA_ARGS__); \
 	} \
 } while (0)