Skip to content

Commit c3b2f32

Browse files
committed
smoke: guard against NULL from malloc() and te_compile()
1 parent 0c1260b commit c3b2f32

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎smoke.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ void test_optimize() {
565565
int err;
566566
te_expr *ex = te_compile(expr, 0, 0, &err);
567567
lok(ex);
568+
if (!ex) continue;
568569

569570
/* The answer should be know without
570571
* even running eval. */
@@ -812,6 +813,7 @@ void test_depth() {
812813

813814
/* ((((...1...)))) */
814815
char *expr = malloc(depth * 2 + 2);
816+
if (!expr) { lok(0); continue; }
815817
memset(expr, '(', depth);
816818
expr[depth] = '1';
817819
memset(expr + depth + 1, ')', depth);
@@ -823,6 +825,7 @@ void test_depth() {
823825

824826
/* sin sin sin ... 1 */
825827
expr = malloc(depth * 4 + 2);
828+
if (!expr) { lok(0); continue; }
826829
for (j = 0; j < depth; ++j) memcpy(expr + j * 4, "sin ", 4);
827830
expr[depth * 4] = '1';
828831
expr[depth * 4 + 1] = '\0';

0 commit comments

Comments
 (0)