Fix memory leaks
This commit is contained in:
parent
ac732ecdb0
commit
808a723969
|
@ -99,6 +99,7 @@ static intfstream_t* open_file(const char *path)
|
||||||
if (!intfstream_open(fd, path, RFILE_MODE_READ, -1))
|
if (!intfstream_open(fd, path, RFILE_MODE_READ, -1))
|
||||||
{
|
{
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,10 +264,10 @@ static int stream_get_serial(intfstream_t *fd, char *serial)
|
||||||
|
|
||||||
static bool file_get_serial(const char *name, size_t offset, size_t size, char *serial)
|
static bool file_get_serial(const char *name, size_t offset, size_t size, char *serial)
|
||||||
{
|
{
|
||||||
intfstream_t *fd = open_file(name);
|
|
||||||
int rv;
|
int rv;
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
ssize_t file_size = -1;
|
ssize_t file_size = -1;
|
||||||
|
intfstream_t *fd = open_file(name);
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -274,7 +275,9 @@ static bool file_get_serial(const char *name, size_t offset, size_t size, char *
|
||||||
intfstream_seek(fd, 0, SEEK_END);
|
intfstream_seek(fd, 0, SEEK_END);
|
||||||
file_size = intfstream_tell(fd);
|
file_size = intfstream_tell(fd);
|
||||||
intfstream_seek(fd, 0, SEEK_SET);
|
intfstream_seek(fd, 0, SEEK_SET);
|
||||||
if (file_size < 0) {
|
|
||||||
|
if (file_size < 0)
|
||||||
|
{
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -289,9 +292,11 @@ static bool file_get_serial(const char *name, size_t offset, size_t size, char *
|
||||||
free(data);
|
free(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
fd = open_memory(data, size);
|
fd = open_memory(data, size);
|
||||||
if (!fd) {
|
if (!fd)
|
||||||
|
{
|
||||||
free(data);
|
free(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -300,6 +305,7 @@ static bool file_get_serial(const char *name, size_t offset, size_t size, char *
|
||||||
rv = stream_get_serial(fd, serial);
|
rv = stream_get_serial(fd, serial);
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
free(data);
|
free(data);
|
||||||
|
free(fd);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,6 +443,7 @@ static bool file_get_crc(const char *name, size_t offset, size_t size, uint32_t
|
||||||
|
|
||||||
rv = stream_get_crc(fd, crc);
|
rv = stream_get_crc(fd, crc);
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
free(data);
|
free(data);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -568,6 +575,7 @@ static void gdi_prune(database_info_handle_t *db, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
free(fd);
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -683,12 +683,16 @@ int gdi_find_track(const char *gdi_path, bool first,
|
||||||
clean:
|
clean:
|
||||||
free(tmp_token);
|
free(tmp_token);
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(tmp_token);
|
free(tmp_token);
|
||||||
if (fd)
|
if (fd)
|
||||||
|
{
|
||||||
intfstream_close(fd);
|
intfstream_close(fd);
|
||||||
|
free(fd);
|
||||||
|
}
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue