changeset 21:180d415c0e59

Avoid switching to a range past the last one. Found with AddressSanitizer.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 17 Feb 2017 23:09:50 +0300
parents b676808a49bc
children 801de8ae9c0b
files ngx_http_bytes_filter_module.c
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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;
         }
     }