diff options
Diffstat (limited to 'src/rewrite.c')
| -rw-r--r-- | src/rewrite.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rewrite.c b/src/rewrite.c index c5a497a..6409686 100644 --- a/src/rewrite.c +++ b/src/rewrite.c @@ -1,4 +1,5 @@ #include <fwd/rewrite.h> +#include <fwd/debug.h> #include <stddef.h> #include <stdlib.h> @@ -11,7 +12,12 @@ struct type_helper { static int rewrite_type_ids(struct type *type, char *orig, char *new) { if (type->k == TYPE_ID && strcmp(type->id, orig) == 0) { - char *r = strdup(new); + char *r = strdupc(new); + if (!r) { + internal_error("failed allocating hole"); + return -1; + } + free(type->id); type->id = r; } @@ -49,7 +55,11 @@ static char *rewrite_hole(char *old, char *new) size_t nn = strlen(new); /* +1 for null terminator */ - char *r = malloc(on + nn + 1); + char *r = mallocc(on + nn + 1); + if (!r) { + internal_error("failed allocating hole rewrite buf"); + return NULL; + } memcpy(r, new, nn); |
