eo lexer - handle malloc failure with longjmp
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 13 Jul 2017 09:12:01 +0000 (18:12 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Sun, 16 Jul 2017 06:56:02 +0000 (15:56 +0900)
handles possible error case nicely

src/lib/eolian/eo_lexer.c

index f525b41..023dbdf 100644 (file)
@@ -1252,6 +1252,11 @@ void
 eo_lexer_context_push(Eo_Lexer *ls)
 {
    Lexer_Ctx *ctx = malloc(sizeof(Lexer_Ctx));
+   if (!ctx)
+     {
+        fprintf(stderr, "eolian: out of memory pushing context\n");
+        longjmp(ls->err_jmp, EINA_TRUE);
+     }
    ctx->line = ls->line_number;
    ctx->column = ls->column;
    ctx->linestr = ls->stream_line;