Fixed possible memory leaks

Fri, 13 Jun 2014 17:43:37 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 13 Jun 2014 17:43:37 +0200
changeset 62
dc22cb54babd
parent 61
2810e55ac99d
child 63
07802719f63d

Fixed possible memory leaks

thermferm/logger.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
--- a/thermferm/logger.c	Wed Jun 04 16:00:35 2014 +0200
+++ b/thermferm/logger.c	Fri Jun 13 17:43:37 2014 +0200
@@ -47,13 +47,13 @@
     	if ((logfile = fopen(name, "a+"))) {
 	    fprintf(logfile, outstr);
 	    fclose(logfile);
-	    free(outstr);
-	    outstr = NULL;
     	} else {
 	    syslog(LOG_NOTICE, "logger: cannot open %s for writing", name);
     	}
     }
 
+    free(outstr);
+    outstr = NULL;
     free(name);
     name = NULL;
 }
--- a/thermferm/server.c	Wed Jun 04 16:00:35 2014 +0200
+++ b/thermferm/server.c	Fri Jun 13 17:43:37 2014 +0200
@@ -252,6 +252,7 @@
 		    fprintf(stdout, "p='%s' q='%s' inp='%s'\n", p, q, inp);
 		    srv_send("ERR");
 		}
+		free(inp);
 	// stopScript
 	// quit
 	// eraseLogs

mercurial