From 73a8c0d6de7943a78546183dcaa5d958666eb8c9 Mon Sep 17 00:00:00 2001 From: Brian Bockelman Date: Sat, 23 Nov 2024 23:31:07 -0600 Subject: [PATCH] Prevent segfault if there's no header passed. --- src/HTTPFile.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HTTPFile.cc b/src/HTTPFile.cc index 0506de7..dff96ee 100644 --- a/src/HTTPFile.cc +++ b/src/HTTPFile.cc @@ -202,7 +202,7 @@ int HTTPFile::Fstat(struct stat *buff) { size_t next_newline = std::string::npos; size_t last_character = headers.size(); while (current_newline != std::string::npos && - current_newline != last_character - 1) { + current_newline != last_character - 1 && last_character) { next_newline = headers.find("\r\n", current_newline + 2); std::string line = substring(headers, current_newline + 2, next_newline);