diff --git a/src/client/http/APIRequest.cpp b/src/client/http/APIRequest.cpp index bfc5b7e03..e304d0f27 100644 --- a/src/client/http/APIRequest.cpp +++ b/src/client/http/APIRequest.cpp @@ -20,6 +20,9 @@ namespace http try { ByteString data = Request::Finish(&result.status); + // Note that at this point it's not safe to use any member of the + // APIRequest object as Request::Finish signals RequestManager + // to delete it. Client::Ref().ParseServerReturn(data, result.status, true); if (result.status == 200 && data.size()) { diff --git a/src/client/http/GetUserInfoRequest.cpp b/src/client/http/GetUserInfoRequest.cpp index 009b097b4..71bde9c1d 100644 --- a/src/client/http/GetUserInfoRequest.cpp +++ b/src/client/http/GetUserInfoRequest.cpp @@ -15,6 +15,9 @@ namespace http { std::unique_ptr user_info; auto result = APIRequest::Finish(); + // Note that at this point it's not safe to use any member of the + // GetUserInfoRequest object as Request::Finish signals RequestManager + // to delete it. if (result.document) { auto &user = (*result.document)["User"]; diff --git a/src/client/http/ImageRequest.cpp b/src/client/http/ImageRequest.cpp index d7fd49de8..d04eb08ae 100644 --- a/src/client/http/ImageRequest.cpp +++ b/src/client/http/ImageRequest.cpp @@ -19,7 +19,12 @@ namespace http std::unique_ptr ImageRequest::Finish() { + int width = Width; + int height = Height; ByteString data = Request::Finish(nullptr); + // Note that at this point it's not safe to use any member of the + // ImageRequest object as Request::Finish signals RequestManager + // to delete it. std::unique_ptr vb; if (data.size()) { @@ -35,7 +40,7 @@ namespace http vb = std::unique_ptr(new VideoBuffer(32, 32)); vb->SetCharacter(14, 14, 'x', 255, 255, 255, 255); } - vb->Resize(Width, Height, true); + vb->Resize(width, height, true); } return vb; } diff --git a/src/client/http/SaveUserInfoRequest.cpp b/src/client/http/SaveUserInfoRequest.cpp index fa61defd1..c7d687ef1 100644 --- a/src/client/http/SaveUserInfoRequest.cpp +++ b/src/client/http/SaveUserInfoRequest.cpp @@ -18,6 +18,9 @@ namespace http bool SaveUserInfoRequest::Finish() { auto result = APIRequest::Finish(); + // Note that at this point it's not safe to use any member of the + // SaveUserInfoRequest object as Request::Finish signals RequestManager + // to delete it. if (result.document) { return (*result.document)["Status"].asInt() == 1;