summaryrefslogtreecommitdiffstats
path: root/dimension/lexer.l
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-03-12 17:17:06 -0500
committerTavian Barnes <tavianator@gmail.com>2010-03-12 17:17:06 -0500
commit13a0ea225fb89fe1928303faf9fa23afe355ab97 (patch)
tree14686117372277f4030b2fec20f29e54b0e864ff /dimension/lexer.l
parent17f12a717ffea58b430affff4951c6527189c990 (diff)
downloaddimension-13a0ea225fb89fe1928303faf9fa23afe355ab97.tar.xz
Check for malloc() failures.
Diffstat (limited to 'dimension/lexer.l')
-rw-r--r--dimension/lexer.l15
1 files changed, 9 insertions, 6 deletions
diff --git a/dimension/lexer.l b/dimension/lexer.l
index 5027d71..4beeee7 100644
--- a/dimension/lexer.l
+++ b/dimension/lexer.l
@@ -81,12 +81,15 @@
RETURN(); \
} while (0)
-#define STRING_TOKEN() \
- do { \
- NEW_TOKEN(DMNSN_T_STRING); \
- lvalp->value = malloc(string_extent); \
- lvalp->value[0] = '\0'; \
- CALCULATE_COLUMN(); \
+#define STRING_TOKEN() \
+ do { \
+ NEW_TOKEN(DMNSN_T_STRING); \
+ lvalp->value = malloc(string_extent); \
+ if (!lvalp->value) \
+ dmnsn_error(DMNSN_SEVERITY_HIGH, \
+ "Couldn't allocate space for token value."); \
+ lvalp->value[0] = '\0'; \
+ CALCULATE_COLUMN(); \
} while (0)
#define STRCAT(str, len) \