test185.c 622 Bytes
Newer Older
1 2 3 4 5 6 7
typedef __crust_t__ unsigned char *crust_t;

#define NULL ((void *)0)

crust_t global_var1;
crust_t global_var2;

8 9
void function2(crust_t);

10 11
void function(crust_t param1) {

12 13 14 15 16 17 18 19
	if ((global_var1 == NULL) && (global_var2 == NULL)) {
		global_var1 = param1; // It is fine: since we are storing the block from "param3" in a global variable, it is not a dangling 	pointer
		global_var2 = global_var1; // It is fine to assign the same block to several global variables
		// Here param1 is not freed, but is OK because it is in a global variable
		__crust_debug__
	} else {
		function(param1); // free param1 to avoid an error
	}
20
}