aboutsummaryrefslogtreecommitdiff
path: root/src/rewrite.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-05-01 20:35:00 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2026-05-01 22:16:26 +0300
commit8946c27306abed7065afad3f015df5ee81e72ad2 (patch)
treec53c9a2c0437109e9c1e3f873bf8a54220ee5ded /src/rewrite.c
parent7790e27b3423901e2080bfd3c600a65a48d42886 (diff)
downloadfwd-8946c27306abed7065afad3f015df5ee81e72ad2.tar.gz
fwd-8946c27306abed7065afad3f015df5ee81e72ad2.zip
add support for coverage
Diffstat (limited to 'src/rewrite.c')
-rw-r--r--src/rewrite.c14
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);