mirror of
				https://github.com/eledio-devices/thirdparty-tinyexpr.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Fixed memory leaks and uninitialized values.
This commit is contained in:
		| @@ -63,6 +63,7 @@ static te_expr *new_expr(const int type, const te_expr *members[]) { | ||||
|     int member_count = te_get_arity(type); | ||||
|     size_t member_size = sizeof(te_expr*) * member_count; | ||||
|     te_expr *ret = malloc(sizeof(te_expr) + member_size); | ||||
|     ret->member_count = member_count; | ||||
|     if(!members) { | ||||
|         memset(ret->members, 0, member_size); | ||||
|     } else { | ||||
| @@ -251,7 +252,7 @@ static te_expr *base(state *s) { | ||||
|             } | ||||
|             break; | ||||
|  | ||||
|         case TOK_FUNCTION1:             | ||||
|         case TOK_FUNCTION1: | ||||
|             ret = new_expr(TE_FUN | 1, 0); | ||||
|             ret->fun.f0 = s->fun.f0; | ||||
|  | ||||
|   | ||||
| @@ -42,13 +42,13 @@ typedef double (*te_fun7)(double, double, double, double, double, double, double | ||||
|  | ||||
| typedef union | ||||
| { | ||||
| 	te_fun0 f0; te_fun1 f1; te_fun2 f2; te_fun3 f3; te_fun4 f4; te_fun5 f5; te_fun6 f6; te_fun7 f7; | ||||
|     te_fun0 f0; te_fun1 f1; te_fun2 f2; te_fun3 f3; te_fun4 f4; te_fun5 f5; te_fun6 f6; te_fun7 f7; | ||||
| } te_fun; | ||||
|  | ||||
| typedef struct te_expr { | ||||
|     int type; | ||||
|     union {double value; const double *bound; te_fun fun; }; | ||||
| 	int member_count; | ||||
|     int member_count; | ||||
|     struct te_expr *members[]; | ||||
| } te_expr; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user