summaryrefslogtreecommitdiffstats
path: root/src/fat.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-01-29 08:53:42 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-01-29 08:53:42 +0100
commit77f095422316289af374a59423e3f0ccc9602ed3 (patch)
tree0e41c6bcd5e0bba49ea3bb3c7429f05a59cab6d0 /src/fat.c
parenta48dbbd42593f8ab889ad3fe678b5d67a2a824b7 (diff)
Fix a few memory leaks found using Coccinelle, http://www.emn.fr/x-info/coccinelle/
Diffstat (limited to 'src/fat.c')
-rw-r--r--src/fat.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/fat.c b/src/fat.c
index d9ee496..1d114b2 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -257,7 +257,9 @@ unsigned int get_next_cluster(disk_t *disk_car,const partition_t *partition, con
offset_o=(cluster+cluster/2)%disk_car->sector_size;
if(disk_car->read(disk_car,2*disk_car->sector_size, buffer, partition->part_offset+(uint64_t)(offset+offset_s)*disk_car->sector_size)!=0)
{
- log_error("get_next_cluster read error\n"); return 0;
+ log_error("get_next_cluster read error\n");
+ free(buffer);
+ return 0;
}
if((cluster&1)!=0)
next_cluster=le16((*((uint16_t*)&buffer[offset_o])))>>4;
@@ -273,7 +275,9 @@ unsigned int get_next_cluster(disk_t *disk_car,const partition_t *partition, con
offset_o=cluster%(disk_car->sector_size/2);
if(disk_car->read(disk_car,disk_car->sector_size, buffer, partition->part_offset+(uint64_t)(offset+offset_s)*disk_car->sector_size)!=0)
{
- log_error("get_next_cluster read error\n"); return 0;
+ log_error("get_next_cluster read error\n");
+ free(buffer);
+ return 0;
}
next_cluster=le16(p16[offset_o]);
free(buffer);
@@ -286,7 +290,9 @@ unsigned int get_next_cluster(disk_t *disk_car,const partition_t *partition, con
offset_o=cluster%(disk_car->sector_size/4);
if(disk_car->read(disk_car,disk_car->sector_size, buffer, partition->part_offset+(uint64_t)(offset+offset_s)*disk_car->sector_size)!=0)
{
- log_error("get_next_cluster read error\n"); return 0;
+ log_error("get_next_cluster read error\n");
+ free(buffer);
+ return 0;
}
/* FAT32 used 28 bits, the 4 high bits are reserved
* 0x00000000: free cluster
@@ -690,11 +696,15 @@ int comp_FAT(disk_t *disk_car,const partition_t *partition,const unsigned long i
if(disk_car->read(disk_car,read_size*disk_car->sector_size, buffer, hd_offset))
{
log_error("comp_FAT: can't read FAT1\n");
+ free(buffer2);
+ free(buffer);
return 1;
}
if(disk_car->read(disk_car,read_size*disk_car->sector_size, buffer2, hd_offset2))
{
log_error("comp_FAT: can't read FAT2\n");
+ free(buffer2);
+ free(buffer);
return 1;
}
if(memcmp(buffer,buffer2,disk_car->sector_size*read_size)!=0)