Skip to content

Commit 58a1c1b

Browse files
authored
Fix a use-after-free bug in BundleTest.CanDeleteFirestoreFromProgressUpdate (#575)
1 parent 2d2e320 commit 58a1c1b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

firestore/integration_test_internal/src/bundle_test.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ TEST_F(BundleTest, CanDeleteFirestoreFromProgressUpdate) {
177177
progresses.push_back(progress);
178178
// Delete firestore before the final progress.
179179
if (progresses.size() == 3) {
180+
// Save `db_deleted` to a local variable because this lambda gets
181+
// deleted by the call to `DeleteFirestore()` below, and therefore it
182+
// is undefined behavior to access any captured variables thereafter.
183+
auto& db_deleted_local = db_deleted;
180184
DeleteFirestore(db);
181-
db_deleted.set_value();
185+
db_deleted_local.set_value();
182186
}
183187
});
184188

0 commit comments

Comments
 (0)