commit 0b834fa2a4e7c252a462a6c24945c269958530dd
parent 8f4e404a0cec279470b94f1e49ed5010b793d6ad
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 14 Aug 2010 20:35:34 +0000
fix leak
Diffstat:
2 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/src/plugins/id3v24_extractor.c b/src/plugins/id3v24_extractor.c
@@ -364,7 +364,11 @@ EXTRACTOR_id3v24_extract (const unsigned char *data,
off++;
if ( (off >= csize) ||
(data[pos+off] != '\0') )
- return 0; /* malformed */
+ {
+ if (mime != NULL)
+ free (mime);
+ return 0; /* malformed */
+ }
off++;
if ( (mime != NULL) &&
(0 == strcasecmp ("-->",
diff --git a/src/plugins/odf_extractor.c b/src/plugins/odf_extractor.c
@@ -196,18 +196,20 @@ EXTRACTOR_odf_extract (const char *data,
return 0; /* hardly meta-data! */
}
buf = malloc(buf_size+1);
- if (buf == NULL) {
- EXTRACTOR_common_unzip_close_current_file(uf);
- EXTRACTOR_common_unzip_close(uf);
- return 0; /* out of memory */
- }
+ if (buf == NULL)
+ {
+ EXTRACTOR_common_unzip_close_current_file(uf);
+ EXTRACTOR_common_unzip_close(uf);
+ return 0; /* out of memory */
+ }
- if (buf_size != EXTRACTOR_common_unzip_read_current_file(uf,buf,buf_size)) {
- free(buf);
- EXTRACTOR_common_unzip_close_current_file(uf);
- EXTRACTOR_common_unzip_close(uf);
- return 0;
- }
+ if (buf_size != EXTRACTOR_common_unzip_read_current_file(uf,buf,buf_size))
+ {
+ free(buf);
+ EXTRACTOR_common_unzip_close_current_file(uf);
+ EXTRACTOR_common_unzip_close(uf);
+ return 0;
+ }
EXTRACTOR_common_unzip_close_current_file(uf);
/* we don't do "proper" parsing of the meta-data but rather use some heuristics
to get values out that we understand */
@@ -223,7 +225,6 @@ EXTRACTOR_odf_extract (const char *data,
char * spos;
char * epos;
char needle[256];
- char * key;
int oc;
pbuf = buf;
@@ -263,24 +264,27 @@ EXTRACTOR_odf_extract (const char *data,
epos++;
}
}
- if (spos != epos) {
- key = malloc(1+epos-spos);
- memcpy(key, spos, epos-spos);
- key[epos-spos] = '\0';
- if (0 != proc (proc_cls,
- "odf",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- key,
- strlen (key)+1))
- {
- free(buf);
- EXTRACTOR_common_unzip_close(uf);
- return 1;
- }
- pbuf = epos;
- } else
+ if (spos != epos)
+ {
+ char key[epos - spos + 1];
+
+ memcpy(key, spos, epos-spos);
+ key[epos-spos] = '\0';
+ if (0 != proc (proc_cls,
+ "odf",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ key,
+ epos - spos + 1))
+ {
+ free(buf);
+ EXTRACTOR_common_unzip_close(uf);
+ return 1;
+ }
+ pbuf = epos;
+ }
+ else
break;
}
}
@@ -290,3 +294,4 @@ EXTRACTOR_odf_extract (const char *data,
return 0;
}
+