Browse code

fix memleaks

Tomasz Kojm authored on 2009/11/24 07:27:14
Showing 1 changed files
... ...
@@ -1678,7 +1678,7 @@ static char *decodehexstr(const char *hex)
1678 1678
 
1679 1679
 static int decodehex(const char *hexsig)
1680 1680
 {
1681
-	char *pt, *hexcpy, *start, *n;
1681
+	char *pt, *hexcpy, *start, *n, *decoded;
1682 1682
 	int asterisk = 0;
1683 1683
 	unsigned int i, j, hexlen, parts = 0;
1684 1684
 	int mindist = 0, maxdist = 0, error = 0;
... ...
@@ -1724,7 +1724,13 @@ static int decodehex(const char *hexsig)
1724 1724
 	    else if(maxdist)
1725 1725
 		mprintf("{WILDCARD_ANY_STRING(LENGTH<=%u)}", maxdist);
1726 1726
 
1727
-	    mprintf("%s", decodehexstr(start));
1727
+	    if(!(decoded = decodehexstr(start))) {
1728
+		mprintf("!Decoding failed\n");
1729
+		free(hexcpy);
1730
+		return -1;
1731
+	    }
1732
+	    mprintf("%s", decoded);
1733
+	    free(decoded);
1728 1734
 
1729 1735
 	    if(i == parts)
1730 1736
 		break;
... ...
@@ -1799,14 +1805,24 @@ static int decodehex(const char *hexsig)
1799 1799
 		mprintf("!Can't extract part %u of partial signature\n", i);
1800 1800
 		return -1;
1801 1801
 	    }
1802
-	    mprintf("%s", decodehexstr(pt));
1802
+	    if(!(decoded = decodehexstr(pt))) {
1803
+		mprintf("!Decoding failed\n");
1804
+		return -1;
1805
+	    }
1806
+	    mprintf("%s", decoded);
1807
+	    free(decoded);
1803 1808
 	    if(i < parts)
1804 1809
 		mprintf("{WILDCARD_ANY_STRING}");
1805 1810
 	    free(pt);
1806 1811
 	}
1807 1812
 
1808 1813
     } else {
1809
-	mprintf("%s", decodehexstr(hexsig));
1814
+	if(!(decoded = decodehexstr(hexsig))) {
1815
+	    mprintf("!Decoding failed\n");
1816
+	    return -1;
1817
+	}
1818
+	mprintf("%s", decoded);
1819
+	free(decoded);
1810 1820
     }
1811 1821
 
1812 1822
     mprintf("\n");