Skip to content

Commit ef28f10

Browse files
authored
Fix crash caused by ResponseJson::MarkCompleted() failing to set application_data_ if parsing the JSON body fails (#692)
1 parent 0631f33 commit ef28f10

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/rest/response_json.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "app/rest/response.h"
2424
#include "app/src/assert.h"
25+
#include "app/src/log.h"
2526
#include "flatbuffers/idl.h"
2627
#include "flatbuffers/stl_emulation.h"
2728

@@ -74,12 +75,24 @@ class ResponseJson : public Response {
7475
// Parse and verify JSON string in body. FlatBuffer parser does not support
7576
// online parsing. So we only parse the body when we get everything.
7677
bool parse_status = parser_->Parse(GetBody());
77-
FIREBASE_ASSERT_RETURN_VOID(parse_status);
78+
if (!parse_status) {
79+
LogError("flatbuffers::Parser::Parse() failed: %s",
80+
parser_->error_.c_str());
81+
application_data_.reset(new FbsTypeT());
82+
Response::MarkCompleted();
83+
return;
84+
}
85+
7886
const flatbuffers::FlatBufferBuilder& builder = parser_->builder_;
7987
flatbuffers::Verifier verifier(builder.GetBufferPointer(),
8088
builder.GetSize());
8189
bool verify_status = verifier.VerifyBuffer<FbsType>(nullptr);
82-
FIREBASE_ASSERT_RETURN_VOID(verify_status);
90+
if (!verify_status) {
91+
LogError("flatbuffers::Verifier::VerifyBuffer() failed");
92+
application_data_.reset(new FbsTypeT());
93+
Response::MarkCompleted();
94+
return;
95+
}
8396

8497
// UnPack application data object from FlatBuffer.
8598
const FbsType* body_fbs =

release_build_files/readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ code.
576576
- Messaging (Android): Fixes an issue to receive token when
577577
initialize the app.
578578
([#667](https://github.com/firebase/firebase-cpp-sdk/pull/667)).
579+
- Auth (Desktop): Fix a crash that would occur if parsing the JSON
580+
response from the server failed
581+
([#692](https://github.com/firebase/firebase-cpp-sdk/pull/692)).
579582

580583
### 8.5.0
581584
- Changes

0 commit comments

Comments
 (0)