From e895730d3ffb677c3bf3c7cc9dc1267968c79d88 Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 27 Aug 2008 21:46:01 +0000 Subject: [PATCH] added some freeing for error conditions git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1467 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_tool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c index f536fa51..80bdb6e7 100644 --- a/program/src/rrd_tool.c +++ b/program/src/rrd_tool.c @@ -364,6 +364,7 @@ static char *fgetslong( return *aLinePtr = linebuf; bufsize += MAX_LENGTH; if (!(linebuf = realloc(linebuf, bufsize))) { + free(linebuf); perror("fgetslong: realloc"); exit(1); } @@ -448,6 +449,7 @@ int main( while (fgetslong(&aLine, stdin)) { if ((argc = CountArgs(aLine)) == 0) { + free(aLine); printf("ERROR: not enough arguments\n"); } if ((myargv = (char **) malloc((argc + 1) * @@ -456,6 +458,8 @@ int main( exit(1); } if ((argc = CreateArgs(argv[0], aLine, argc, myargv)) < 0) { + free(aLine); + free(myargv); printf("ERROR: creating arguments\n"); } else { int ret = HandleInputLine(argc, myargv, stdout); -- 2.30.2