diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-01-05 22:09:49 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-01-05 22:09:49 (GMT) |
commit | 2a429fde26212e8c8c9a5a44f9a4a06ee60a5208 (patch) | |
tree | d5456f3c83d1faffdda1784b04d3ae59efde5ae0 /tools/d2c/hooks | |
parent | e790ebee8ad78e91fc61738c5c40062ed36b1d44 (diff) |
Fortified the d2c compiler by checking asprint() return values.
Diffstat (limited to 'tools/d2c/hooks')
-rw-r--r-- | tools/d2c/hooks/tokens.l | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/d2c/hooks/tokens.l b/tools/d2c/hooks/tokens.l index 1f72d2c..57a445b 100644 --- a/tools/d2c/hooks/tokens.l +++ b/tools/d2c/hooks/tokens.l @@ -23,9 +23,15 @@ . { char *msg; - asprintf(&msg, "Unhandled token in d2c hooks block: '%s'", yytext); - YY_FATAL_ERROR(msg); - free(msg); + int ret; + ret = asprintf(&msg, "Unhandled token in d2c hooks block: '%s'", yytext); + if (ret == -1) + YY_FATAL_ERROR("Unhandled token in undisclosed d2c hooks block"); + else + { + YY_FATAL_ERROR(msg); + free(msg); + } } |