... | ... |
@@ -2073,6 +2073,9 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2073 | 2073 |
unsigned int i, len = 0, hlen, negative, altnum, alttype; |
2074 | 2074 |
char *buff; |
2075 | 2075 |
|
2076 |
+ |
|
2077 |
+ hexcpy = NULL; |
|
2078 |
+ buff = NULL; |
|
2076 | 2079 |
|
2077 | 2080 |
hexcpy = strdup(hex); |
2078 | 2081 |
if(!hexcpy) { |
... | ... |
@@ -2087,6 +2090,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2087 | 2087 |
buff = calloc(strlen(hex) + 512, sizeof(char)); |
2088 | 2088 |
if(!buff) { |
2089 | 2089 |
mprintf("!decodehexspecial: Can't allocate memory for buff\n"); |
2090 |
+ free(hexcpy); |
|
2090 | 2091 |
return NULL; |
2091 | 2092 |
} |
2092 | 2093 |
start = hexcpy; |
... | ... |
@@ -2095,6 +2099,8 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2095 | 2095 |
*pt++ = 0; |
2096 | 2096 |
if(!start) { |
2097 | 2097 |
mprintf("!decodehexspecial: Unexpected EOL\n"); |
2098 |
+ free(hexcpy); |
|
2099 |
+ free(buff); |
|
2098 | 2100 |
return NULL; |
2099 | 2101 |
} |
2100 | 2102 |
if(pt >= hexcpy + 2) { |
... | ... |
@@ -2106,6 +2112,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2106 | 2106 |
if(!(decoded = decodehexstr(start, &hlen))) { |
2107 | 2107 |
mprintf("!Decoding failed (1): %s\n", pt); |
2108 | 2108 |
free(hexcpy); |
2109 |
+ free(buff); |
|
2109 | 2110 |
return NULL; |
2110 | 2111 |
} |
2111 | 2112 |
memcpy(&buff[len], decoded, hlen); |
... | ... |
@@ -2115,6 +2122,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2115 | 2115 |
if(!(start = strchr(pt, ')'))) { |
2116 | 2116 |
mprintf("!decodehexspecial: Missing closing parethesis\n"); |
2117 | 2117 |
free(hexcpy); |
2118 |
+ free(buff); |
|
2118 | 2119 |
return NULL; |
2119 | 2120 |
} |
2120 | 2121 |
|
... | ... |
@@ -2122,6 +2130,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2122 | 2122 |
if(!strlen(pt)) { |
2123 | 2123 |
mprintf("!decodehexspecial: Empty block\n"); |
2124 | 2124 |
free(hexcpy); |
2125 |
+ free(buff); |
|
2125 | 2126 |
return NULL; |
2126 | 2127 |
} |
2127 | 2128 |
|
... | ... |
@@ -2162,6 +2171,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2162 | 2162 |
if(!altnum) { |
2163 | 2163 |
mprintf("!decodehexspecial: Empty block\n"); |
2164 | 2164 |
free(hexcpy); |
2165 |
+ free(buff); |
|
2165 | 2166 |
return NULL; |
2166 | 2167 |
} |
2167 | 2168 |
altnum++; |
... | ... |
@@ -2183,12 +2193,14 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2183 | 2183 |
for(i = 0; i < altnum; i++) { |
2184 | 2184 |
if(!(h = cli_strtok(pt, i, "|"))) { |
2185 | 2185 |
free(hexcpy); |
2186 |
+ free(buff); |
|
2186 | 2187 |
return NULL; |
2187 | 2188 |
} |
2188 | 2189 |
|
2189 | 2190 |
if(!(c = cli_hex2str(h))) { |
2190 | 2191 |
free(h); |
2191 | 2192 |
free(hexcpy); |
2193 |
+ free(buff); |
|
2192 | 2194 |
return NULL; |
2193 | 2195 |
} |
2194 | 2196 |
|
... | ... |
@@ -2208,6 +2220,7 @@ static char *decodehexspecial(const char *hex, unsigned int *dlen) |
2208 | 2208 |
if(start) { |
2209 | 2209 |
if(!(decoded = decodehexstr(start, &hlen))) { |
2210 | 2210 |
mprintf("!Decoding failed (2)\n"); |
2211 |
+ free(buff); |
|
2211 | 2212 |
free(hexcpy); |
2212 | 2213 |
return NULL; |
2213 | 2214 |
} |