Fix gigantic memory leak
This commit is contained in:
parent
7130df6469
commit
fcf1918438
|
@ -306,10 +306,12 @@ int daap_serialize(DAAP_BLOCK *root, int fd, int gzip) {
|
||||||
uncompressed=(char*)malloc(uncompressed_len+1);
|
uncompressed=(char*)malloc(uncompressed_len+1);
|
||||||
if(!uncompressed) {
|
if(!uncompressed) {
|
||||||
DPRINTF(ERR_INFO,"Error allocating serialization block\n");
|
DPRINTF(ERR_INFO,"Error allocating serialization block\n");
|
||||||
|
daap_free(root);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
daap_serialmem(root,uncompressed);
|
daap_serialmem(root,uncompressed);
|
||||||
|
daap_free(root);
|
||||||
|
|
||||||
if(gzip) {
|
if(gzip) {
|
||||||
/* guarantee enough buffer space */
|
/* guarantee enough buffer space */
|
||||||
|
@ -395,10 +397,13 @@ int daap_compress(char *input, long in_len, char *output, long *out_len) {
|
||||||
* Free an entire daap formatted block
|
* Free an entire daap formatted block
|
||||||
*/
|
*/
|
||||||
int daap_free(DAAP_BLOCK *root) {
|
int daap_free(DAAP_BLOCK *root) {
|
||||||
|
if(!root)
|
||||||
|
return;
|
||||||
|
|
||||||
if((root->size)&&(root->free))
|
if((root->size)&&(root->free))
|
||||||
free(root->value);
|
free(root->value);
|
||||||
free(root->children);
|
daap_free(root->children);
|
||||||
free(root->next);
|
daap_free(root->next);
|
||||||
free(root);
|
free(root);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue