Browse code

Fix obscure chance of memory leak

git-svn: trunk@1097

Nigel Horne authored on 2004/11/15 22:58:50
Showing 1 changed files
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.178  2004/11/15 13:58:50  nigelhorne
21
+ * Fix obscure chance of memory leak
22
+ *
20 23
  * Revision 1.177  2004/11/12 22:22:21  nigelhorne
21 24
  * Performance speeded up
22 25
  *
... ...
@@ -519,7 +522,7 @@
519 519
  * Compilable under SCO; removed duplicate code with message.c
520 520
  *
521 521
  */
522
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.177 2004/11/12 22:22:21 nigelhorne Exp $";
522
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.178 2004/11/15 13:58:50 nigelhorne Exp $";
523 523
 
524 524
 #if HAVE_CONFIG_H
525 525
 #include "clamav-config.h"
... ...
@@ -2302,6 +2305,7 @@ static int
2302 2302
 boundaryStart(const char *line, const char *boundary)
2303 2303
 {
2304 2304
 	char *ptr, *p;
2305
+	int rc;
2305 2306
 
2306 2307
 	if(line == NULL)
2307 2308
 		return 0;	/* empty line */
... ...
@@ -2333,17 +2337,20 @@ boundaryStart(const char *line, const char *boundary)
2333 2333
 	 * boundary="1" we want to ensure that we don't break out of every line
2334 2334
 	 * that has -1 in it instead of starting --1. This needs some more work.
2335 2335
 	 */
2336
-	if(strstr(ptr, boundary) != NULL) {
2337
-		cli_dbgmsg("boundaryStart: found %s in %s\n", boundary, line);
2338
-		if(p)
2339
-			free(p);
2340
-		return 1;
2341
-	}
2342
-	if(*ptr++ != '-')
2343
-		return 0;
2336
+	if(strstr(ptr, boundary) != NULL)
2337
+		rc = 1;
2338
+	else if(*ptr++ != '-')
2339
+		rc = 0;
2340
+	else
2341
+		rc = (strcasecmp(line, boundary) == 0);
2342
+
2344 2343
 	if(p)
2345 2344
 		free(p);
2346
-	return strcasecmp(line, boundary) == 0;
2345
+
2346
+	if(rc == 1)
2347
+		cli_dbgmsg("boundaryStart: found %s in %s\n", boundary, line);
2348
+
2349
+	return rc;
2347 2350
 }
2348 2351
 
2349 2352
 /*