# HG changeset patch # User Maxim Dounin # Date 1487362190 -10800 # Node ID 180d415c0e5985027b8f651beec98e9a136c570c # Parent b676808a49bc65d22a9032d6d8faedf6de676d71 Avoid switching to a range past the last one. Found with AddressSanitizer. diff --git a/ngx_http_bytes_filter_module.c b/ngx_http_bytes_filter_module.c --- a/ngx_http_bytes_filter_module.c +++ b/ngx_http_bytes_filter_module.c @@ -543,18 +543,18 @@ fixup: b->pos, b->last); } - if (range->end < ctx->offset + size) { + if (range->end < ctx->offset + size + && range < last - 1) + { range++; - if (range < last) { - ctx->range = range; + ctx->range = range; - if (range->start > ctx->offset + size) { - continue; - } + if (range->start > ctx->offset + size) { + continue; + } - /* next range in same buffer */ - goto next; - } + /* next range in same buffer */ + goto next; } }