2017年6月21日 星期三

[lookback] causing "double free or corruption (out)"

remember do not use comma part beneath:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
//void *data;
//data=calloc(1,sizeof(struct erase_count_table));
//if(data==NULL)
//{
// printf("get buffer for ec table failed.\n");
 return 1;
//}
//memset(data,0,sizeof(struct erase_count_table));
//if(ec_table->max_ec)
ecbackup.max_ec=ec_table->max_ec;
ecbackup.avg_ec=ec_table->avg_ec;
ecbackup.min_ec=ec_table->min_ec;
if(fgLiteon&& (bGEN != GEN_AD1) && (bGEN != GEN_CB1_SD))
{
 //err=ltn_get_ec_table(fd, (void*)ec_table);//nvmad(0xFE, 0, 0x80, 0,0x16, 0, 1, 0x4356544C)
 //err=ltn_get_ec_table(fd, data);
 err=ltn_get_ec_table(fd, ec_table);
 //ec_table=(struct erase_count_table *)data;
 show_ec_table(ec_table);
}
//free(data);

when free(data); at the end, gcc compiler alarms with
"free(): invalid next size (fast): 0x0000000001018120 ***"

because sizeof(struct erase_count_table) is beneath 512, and BU command need above 512 byte.

so change calloc size to 512 is worked.

沒有留言:

張貼留言