aboutsummaryrefslogtreecommitdiffstats
path: root/datatrak.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-06 22:34:11 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-06 22:46:44 +0100
commit4eb0c77d8578190efbd8fa10ed6665968e1a4379 (patch)
tree70dfae57ceefa0c59237f94469ba30bebefc28ed /datatrak.h
parent415d3501da64cfcbe098507749c796513d47ed90 (diff)
downloadsubsurface-4eb0c77d8578190efbd8fa10ed6665968e1a4379.tar.gz
Avoid leaking memory
Coverity CID 1325756 and others Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'datatrak.h')
-rw-r--r--datatrak.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/datatrak.h b/datatrak.h
index 1b518ce10..3a37e0465 100644
--- a/datatrak.h
+++ b/datatrak.h
@@ -31,8 +31,10 @@ typedef struct dtrakheader_ {
#define read_string(_property) \
unsigned char *_property##tmp = (unsigned char *)calloc(tmp_1byte + 1, 1); \
- if (fread((char *)_property##tmp, 1, tmp_1byte, archivo) != tmp_1byte) \
+ if (fread((char *)_property##tmp, 1, tmp_1byte, archivo) != tmp_1byte) { \
+ free(_property##tmp); \
goto bail; \
+ } \
_property = (unsigned char *)strcat(to_utf8(_property##tmp), ""); \
free(_property##tmp);