nodejs / http-parser

http request/response parser for c
MIT License
6.33k stars 1.53k forks source link

Fix bad pointer arithmetic #474

Closed bnoordhuis closed 5 years ago

bnoordhuis commented 5 years ago

The bad arithmetic didn't result in wrong or insecure behavior (there were no out-of-bound accesses and forward progress was still being made because of the outer loop) but it did regress the performance of header field parsing rather massively.

Taking the test suite as an example: the inner fast path loop was skipped over 4.4 million times, falling back to the outer slow path loop. After this commit that only happens about 2,000 times - a 2,200-fold reduction.

Fixes: https://github.com/nodejs/http-parser/issues/473