aboutsummaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/debug.c b/src/debug.c
index 2426277..d229ae6 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <stdarg.h>
+#include <fwd/tracker.h>
#include <fwd/debug.h>
#include <fwd/scope.h>
@@ -272,8 +273,15 @@ static void _type_str(FILE *f, struct type *type)
char *type_str(struct type *t)
{
- if (!t)
- return strdup("NULL");
+ if (!t) {
+ char *s = strdupc("NULL");
+ if (!s) {
+ internal_error("failed allocating null string");
+ return NULL;
+ }
+
+ return s;
+ }
char *buf = NULL; size_t size = 0;
FILE *memstream = open_memstream(&buf, &size);
@@ -283,6 +291,8 @@ char *type_str(struct type *t)
_type_str(memstream, t);
fclose(memstream);
+
+ track_ptr(buf);
return buf;
}