Subject: Re: few more fixes for iproute2/m_ipt

From: Denys Fedoryshchenko <[email-masked]>
Date: Wed, 6 Aug 2008 15:50:41 +0300

On Wednesday 06 August 2008, jamal wrote:
> cheers,
> jamal
> PS:- dont wanna sound anal - and you dont have to do this if you dont
> have time; but if you put the resetting of optind and the flags in a
> separate patch from the freeing, that would be even better.
Yes, i did already
Attaching patches

diff -Naur iproute2-original/tc/m_ipt.c iproute2-patched/tc/m_ipt.c
--- iproute2-original/tc/m_ipt.c	2008-08-05 19:15:56.000000000 +0000
+++ iproute2-patched/tc/m_ipt.c	2008-08-06 11:13:47.000000000 +0000
@@ -277,6 +277,8 @@
 		if (!handle) {
 			fputs(dlerror(), stderr);
 			printf("\n");
+			free(l_name);
+			free(new_name);
 			return NULL;
 		}
 	}
@@ -292,12 +294,16 @@
 					fputs(error, stderr);
 					fprintf(stderr, "\n");
 					dlclose(handle);
+					free(l_name);
+					free(new_name);
 					return NULL;
 				}
 			}
 		}
 	}
 
+	free(l_name);
+	free(new_name);
 	return m;
 }
 
@@ -514,6 +520,13 @@
 
 	optind = 1;
 	free_opts(opts);
+	/* Clear flags if target will be used again */
+        m->tflags=0;
+        m->used=0;
+	/* Free allocated memory */
+        if (m->t)
+            free(m->t);
+
 
 	return 0;
 
diff -Naur iproute2-patched/tc/m_ipt.c iproute2-patched2/tc/m_ipt.c
--- iproute2-patched/tc/m_ipt.c	2008-08-06 11:13:47.000000000 +0000
+++ iproute2-patched2/tc/m_ipt.c	2008-08-06 11:14:58.000000000 +0000
@@ -518,7 +518,7 @@
 	*argc_p = rargc - iargc;
 	*argv_p = argv;
 
-	optind = 1;
+	optind = 0;
 	free_opts(opts);
 	/* Clear flags if target will be used again */
         m->tflags=0;