mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-24 10:32:32 +00:00
Add checks for realloc() result
This commit is contained in:
parent
07b8b22c9b
commit
b58a9260bd
@ -21,6 +21,7 @@
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "mon.h"
|
||||
#include "mon_cmd.h"
|
||||
@ -84,11 +85,13 @@ start:
|
||||
if (mon_token == T_STRING) {
|
||||
unsigned n = strlen(mon_string);
|
||||
str = (uint8 *)realloc(str, (len + n - 1 + GRANULARITY) & ~(GRANULARITY - 1));
|
||||
assert(str != NULL);
|
||||
memcpy(str + len, mon_string, n);
|
||||
len += n;
|
||||
mon_get_token();
|
||||
} else if (mon_expression(&value)) {
|
||||
str = (uint8 *)realloc(str, (len + GRANULARITY) & ~(GRANULARITY - 1));
|
||||
assert(str != NULL);
|
||||
str[len] = value;
|
||||
len++;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user