summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-06 14:19:42 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-06 14:19:42 -0800
commit3e8e005aa322784ace8b342b9509c831042708f5 (patch)
tree2cce3c030125b63d42a3cabdd593d728e30e6763
parent20d9cf19d7d5d1989239a50790c481b0cb1604da (diff)
downloadsubsurface-3e8e005aa322784ace8b342b9509c831042708f5.tar.gz
Deal with theoretical memory leaks
This is rather academic, but it will make Coverity happy. If we start running out of memory we should make sure we don't leak any more memory. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/file.c b/file.c
index af9716ed3..302989408 100644
--- a/file.c
+++ b/file.c
@@ -126,6 +126,12 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, char
endtag = malloc(4 + strlen(tag));
if (starttag == NULL || endtag == NULL) {
+ /* this is fairly silly - so the malloc fails, but we strdup the error?
+ * let's complete the silliness by freeing the two pointers in case one malloc succeeded
+ * and the other one failed - this will make static analysis tools happy */
+ free(starttag);
+ free(endtag);
+ free(buf);
*error = strdup("Memory allocation failed in __func__\n");
return 1;
}