]> git.kaiwu.me - nginx.git/commitdiff
Mp4: avoid adding or comparing to null pointer
authorRoman Arutyunyan <arut@nginx.com>
Mon, 27 Apr 2026 05:40:16 +0000 (09:40 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Fri, 15 May 2026 12:20:30 +0000 (16:20 +0400)
It is considered undefined behavior.

Reported by Geonwoo.kim (awo@kakao.com).

src/http/modules/ngx_http_mp4_module.c

index 678d6296c9286d724a64c93072d03bbfab096dbc..0ccdf135a58ad3d1692ef95373486c6a7e3aa3db 100644 (file)
@@ -1063,7 +1063,9 @@ ngx_http_mp4_read(ngx_http_mp4_file_t *mp4, size_t size)
 {
     ssize_t  n;
 
-    if (mp4->buffer_pos + size <= mp4->buffer_end) {
+    if (mp4->buffer_pos && mp4->buffer_end
+        && mp4->buffer_pos + size <= mp4->buffer_end)
+    {
         return NGX_OK;
     }