Reputation: 1485
This bit of C code is giving segmentation error in gdb
if ((seq_entry_action=malloc((seq_subphases)*sizeof(int*)))==NULL){
printf("Cannot allocate memory for seq_entry_action\n");
}
where:
int **seq_entry_action=NULL;
unsigned int seq_subphases=0;
At the time of executing, and If I add a breakpoint in gdb just before this snippet of code (it's just another printf() statement) , the values are
(gdb) p seq_subphases
$3 = 88
(gdb) p seq_entry_action
$4 = (int **) 0x0
then I press next and it segfaults at malloc
I really don't get it.....
Upvotes: 7
Views: 282
Reputation: 1485
it was like that indeed... an earlier malloc of wrongly computed sizeof() was the reason this malloc failed.
Upvotes: 1