aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-19 19:02:29 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-19 19:02:29 +0000
commitd9be7567d1b18eea0aad9ffbffe1be3b4c1d1055 (patch)
treed3e613d62925ee7349de0cb8e75ca65bf028ab72 /main
parentd0d7e3bf12db11e9f0c20233b45180521b1ffeb5 (diff)
Don't call strlen() when we only need to look at the next character or two.
(closes issue #18042) Reported by: wdoekes Patches: astsvn-inefficient-ast-uri-decode.patch uploaded by wdoekes (license 717) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@302554 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main/utils.c b/main/utils.c
index 51f1283b5..cdf07451d 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -419,7 +419,7 @@ void ast_uri_decode(char *s)
unsigned int tmp;
for (o = s; *s; s++, o++) {
- if (*s == '%' && strlen(s) > 2 && sscanf(s + 1, "%2x", &tmp) == 1) {
+ if (*s == '%' && s[1] != '\0' && s[2] != '\0' && sscanf(s + 1, "%2x", &tmp) == 1) {
/* have '%', two chars and correct parsing */
*o = tmp;
s += 2; /* Will be incremented once more when we break out */