Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logger related crash when HTTP response is empty. #9202

Merged
merged 1 commit into from Oct 29, 2020

Conversation

WamWooWam
Copy link
Contributor

@WamWooWam WamWooWam commented Oct 27, 2020

Fixes a regression introduced by #9187 where Dolphin would crash to desktop in the event the HTTP server returned a zero-length error response, which the update server appears to do occasionally.

The exception in question seems intentional in the logger so I've added a case to make sure there is response body before trying to log it.

EDIT: This crash can also happen when GameTDB doesn't have covers for a game in your library and Dolphin attempts to download it.

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a no-brainer to me. Code looks good, untested.

@@ -221,8 +221,16 @@ HttpRequest::Response HttpRequest::Impl::Fetch(const std::string& url, Method me
curl_easy_getinfo(m_curl.get(), CURLINFO_RESPONSE_CODE, &response_code);
if (response_code != 200)
{
ERROR_LOG_FMT(COMMON, "Failed to {} {}: server replied with code {} and body\n\x1b[0m{:.{}}",
type, url, response_code, buffer.data(), static_cast<int>(buffer.size()));
if (buffer.size() != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be inverted and changed into the more concise if (buffer.empty())

@lioncash
Copy link
Member

Commit message should probably match the PR title as well.

@WamWooWam
Copy link
Contributor Author

That should do it

@leoetlino leoetlino merged commit f665dda into dolphin-emu:master Oct 29, 2020
10 checks passed
@WamWooWam WamWooWam deleted the patch-http-requests branch October 30, 2020 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants