diff options
author | cflip <cflip@cflip.net> | 2023-03-26 10:33:27 -0600 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2023-03-26 10:33:27 -0600 |
commit | ce446addbf5dad34c0726a8150d0c6c897e04366 (patch) | |
tree | 5ad4f5d02d557f80f79921b150beeb8a42b4074a | |
parent | f8ac67c943244aa57e5f848ca6b1f66eca32e138 (diff) |
Avoid possible null pointer dereferenceoriginal-cpp
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.
-rw-r--r-- | src/main.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; |