Skip to content

Commit cd93ee1

Browse files
committed
Fix 2 segfault issues (function call without params + some functions like (a+b+c) )
1 parent 666f516 commit cd93ee1

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

btree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ BoolNode* btree_newLeaf(int b) {
3737

3838
int btree_equals(BoolNode* a, BoolNode* b) {
3939
if(a==0) return (b==0);
40+
if(b==0) return FALSE;
4041
if(a->left==0) return b!=0 && b->left==0 && a->val == b->val;
4142
return btree_equals(a->left, b->left) && btree_equals(a->right, b->right);
4243
}

interpreter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ extern TPA_Expr* pa_newCall(char* s, TPA_Expr** params) {
299299
strcpy(cpy, s);
300300
t -> type = TPA_CALL;
301301
t -> call = cpy;
302-
t -> point = TPAExpr_toPoint(params);
302+
t -> point = (params==0) ? point_init(0) : TPAExpr_toPoint(params);
303303
return t;
304304
}
305305

point.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Point point_init(int dim) {
88
Point p;
99
p.dim = dim;
10-
p.vect = (Bool*)calloc(dim, sizeof(Bool));
10+
p.vect = dim==0 ? 0 : (Bool*)calloc(dim, sizeof(Bool));
1111
return p;
1212
}
1313

0 commit comments

Comments
 (0)