check_http: Handle chunked encoding without actual content correctly

This commit is contained in:
RincewindsHat 2023-02-06 11:39:44 +01:00
parent fc8a233854
commit 6d3e44d2d8

View file

@ -1462,7 +1462,13 @@ char *unchunk_content(const char *content) {
memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
}
result[overall_size] = '\0';
if (overall_size == 0 && result == NULL) {
// We might just have received the end chunk without previous content, so result is never allocated
result = calloc(1, sizeof(char));
// No error handling here, we can only return NULL anyway
} else {
result[overall_size] = '\0';
}
return result;
}