mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-22 03:34:05 -04:00
fix some really ugly memory leaks
This commit is contained in:
parent
9559452124
commit
8577bec027
@ -1057,7 +1057,7 @@ int db_playlist_items_enum_end(ENUMHANDLE handle) {
|
|||||||
* Find a MP3FILE entry based on file id
|
* Find a MP3FILE entry based on file id
|
||||||
*/
|
*/
|
||||||
MP3FILE *db_find(int id) { /* FIXME: Not reentrant */
|
MP3FILE *db_find(int id) { /* FIXME: Not reentrant */
|
||||||
static MP3FILE *pmp3=NULL;
|
MP3FILE *pmp3=NULL;
|
||||||
datum key, content;
|
datum key, content;
|
||||||
|
|
||||||
key.dptr=(char*)&id;
|
key.dptr=(char*)&id;
|
||||||
@ -1068,16 +1068,12 @@ MP3FILE *db_find(int id) { /* FIXME: Not reentrant */
|
|||||||
if(!content.dptr)
|
if(!content.dptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if(pmp3) {
|
|
||||||
db_freefile(pmp3);
|
|
||||||
free(pmp3);
|
|
||||||
}
|
|
||||||
|
|
||||||
pmp3=(MP3FILE*)malloc(sizeof(MP3FILE));
|
pmp3=(MP3FILE*)malloc(sizeof(MP3FILE));
|
||||||
if(!pmp3)
|
if(!pmp3)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
db_unpackrecord(&content,pmp3);
|
db_unpackrecord(&content,pmp3);
|
||||||
|
free(content.dptr);
|
||||||
return pmp3;
|
return pmp3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,7 +1190,7 @@ int db_exists(int id) {
|
|||||||
MP3FILE *pmp3;
|
MP3FILE *pmp3;
|
||||||
datum key,content;
|
datum key,content;
|
||||||
|
|
||||||
DPRINTF(ERR_DEBUG,"Checking if node %d in db\n");
|
DPRINTF(ERR_DEBUG,"Checking if node %d in db\n",id);
|
||||||
key.dptr=(char*)&id;
|
key.dptr=(char*)&id;
|
||||||
key.dsize=sizeof(int);
|
key.dsize=sizeof(int);
|
||||||
|
|
||||||
@ -1237,6 +1233,10 @@ int db_last_modified(int id) {
|
|||||||
retval=pmp3->time_modified;
|
retval=pmp3->time_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pmp3) {
|
||||||
|
db_freefile(pmp3);
|
||||||
|
free(pmp3);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user