From ce446addbf5dad34c0726a8150d0c6c897e04366 Mon Sep 17 00:00:00 2001 From: cflip Date: Sun, 26 Mar 2023 10:33:27 -0600 Subject: Avoid possible null pointer dereference This line dereferenced the beginning of a string to read a single char, but it needed a check to make sure there was at least one char to read in the string. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 4937f0d..64ac80e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ static HttpResponse serve_from_filesystem(const HttpRequest& request) // Remove leading slash from the path if it exists std::string relative_request_path = request.uri(); - while (*relative_request_path.begin() == '/') + while (relative_request_path.length() > 0 && *relative_request_path.begin() == '/') relative_request_path.erase(0, 1); fs::path request_path = fs::current_path() / relative_request_path; -- cgit v1.2.3