http1: fix potential NULL dereference in Curl_h1_req_parse_read()

Reported by clang-tidy v22 with `clang-analyzer-*` explicitly enabled:

```
lib/http1.c:89:31: error: Subtraction of a non-null pointer
 (from variable 'line_end') and a null pointer (via field 'line')
 results in undefined behavior [clang-analyzer-core.NullPointerArithm]
   89 |   parser->line_len = line_end - parser->line + 1;
      |                               ^
```
Ref: https://github.com/curl/curl/actions/runs/22534731241/job/65279952830?pr=20778#step:11:85

Ref: #20778

Closes #20779
This commit is contained in:
Viktor Szakats 2026-03-01 04:46:39 +01:00
parent 7fe5b933d8
commit da6fbb12a6
No known key found for this signature in database

View File

@ -269,6 +269,11 @@ CURLcode Curl_h1_req_parse_read(struct h1_req_parser *parser,
size_t nread;
*pnread = 0;
DEBUGASSERT(buf);
if(!buf)
return CURLE_BAD_FUNCTION_ARGUMENT;
while(!parser->done) {
result = next_line(parser, buf, buflen, options, &nread);
if(result) {