Skip to content

Commit

Permalink
Yahttp router: avoid unsigned underflow in route()
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Jul 17, 2024
1 parent 9adc8b5 commit 63afaec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ext/yahttp/yahttp/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ namespace YaHTTP {
while(k2 < static_cast<int>(req->url.path.size()) && req->url.path[k2] != url[k1+1]) k2++;
pos2 = k2;
params[pname] = funcptr::tie(pos1,pos2);
if (k2 > 0) {
k2--;
}
else {
// If k2 is zero, do not decrement it and then increment at bottom of loop
// Only increment k1 and continue loop
k1++;
continue;
}
}
k2--;
}
else if (url[k1] != req->url.path[k2]) {
break;
Expand Down

0 comments on commit 63afaec

Please sign in to comment.