summaryrefslogtreecommitdiff
path: root/tools/d2c/tokens.l
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-01-05 22:09:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-01-05 22:09:49 (GMT)
commit2a429fde26212e8c8c9a5a44f9a4a06ee60a5208 (patch)
treed5456f3c83d1faffdda1784b04d3ae59efde5ae0 /tools/d2c/tokens.l
parente790ebee8ad78e91fc61738c5c40062ed36b1d44 (diff)
Fortified the d2c compiler by checking asprint() return values.
Diffstat (limited to 'tools/d2c/tokens.l')
-rw-r--r--tools/d2c/tokens.l14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/d2c/tokens.l b/tools/d2c/tokens.l
index 6d32e33..4bd90d6 100644
--- a/tools/d2c/tokens.l
+++ b/tools/d2c/tokens.l
@@ -119,10 +119,16 @@
<*>. {
char *msg;
- asprintf(&msg, "Unhandled token in d2c definition: '%s'", yytext);
- YY_FATAL_ERROR(msg);
- free(msg);
- }
+ int ret;
+ ret = asprintf(&msg, "Unhandled token in d2c definition: '%s'", yytext);
+ if (ret == -1)
+ YY_FATAL_ERROR("Unhandled token in undisclosed d2c definition");
+ else
+ {
+ YY_FATAL_ERROR(msg);
+ free(msg);
+ }
+ }
%%