Browse code

shared/optparser.c: fix small memleak

git-svn: trunk@4574

Tomasz Kojm authored on 2008/12/23 00:01:59
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Dec 22 16:12:27 CET 2008 (tk)
2
+---------------------------------
3
+ * shared/optparser.c: fix small memleak
4
+
1 5
 Thu Dec 18 20:52:00 CET 2008 (tk)
2 6
 ---------------------------------
3 7
  * shared/optparser.c, freshclam: use the new option parser (bb#1215)
... ...
@@ -446,6 +446,7 @@ static int optaddarg(struct optstruct *opts, const char *name, const char *strar
446 446
     if(pt->multiple) {
447 447
 	if(!pt->active) {
448 448
 	    if(strarg) {
449
+		free(pt->strarg);
449 450
 		pt->strarg = strdup(strarg);
450 451
 	 	if(!pt->strarg) {
451 452
 		    fprintf(stderr, "ERROR: optaddarg: strdup() failed\n");
... ...
@@ -478,6 +479,7 @@ static int optaddarg(struct optstruct *opts, const char *name, const char *strar
478 478
 	    return 0;
479 479
 
480 480
 	if(strarg) {
481
+	    free(pt->strarg);
481 482
 	    pt->strarg = strdup(strarg);
482 483
 	    if(!pt->strarg) {
483 484
 		fprintf(stderr, "ERROR: optaddarg: strdup() failed\n");