diff options
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -268,19 +268,20 @@ int hextoint(char c) | |||
268 | 268 | ||
269 | char *convert_query_hexchar(char *txt) | 269 | char *convert_query_hexchar(char *txt) |
270 | { | 270 | { |
271 | int d1, d2; | 271 | int d1, d2, n; |
272 | if (strlen(txt) < 3) { | 272 | n = strlen(txt); |
273 | if (n < 3) { | ||
273 | *txt = '\0'; | 274 | *txt = '\0'; |
274 | return txt-1; | 275 | return txt-1; |
275 | } | 276 | } |
276 | d1 = hextoint(*(txt+1)); | 277 | d1 = hextoint(*(txt+1)); |
277 | d2 = hextoint(*(txt+2)); | 278 | d2 = hextoint(*(txt+2)); |
278 | if (d1<0 || d2<0) { | 279 | if (d1<0 || d2<0) { |
279 | strcpy(txt, txt+3); | 280 | memmove(txt, txt+3, n-3); |
280 | return txt-1; | 281 | return txt-1; |
281 | } else { | 282 | } else { |
282 | *txt = d1 * 16 + d2; | 283 | *txt = d1 * 16 + d2; |
283 | strcpy(txt+1, txt+3); | 284 | memmove(txt+1, txt+3, n-2); |
284 | return txt; | 285 | return txt; |
285 | } | 286 | } |
286 | } | 287 | } |