Commit 0426070
authored
Fix ODR violation of FirestoreInternal in integration_test_util.cc (#559)
In the `TestFriend::CreateTestFirestoreInternal()` method defined in [integration_test_util.cc](https://github.com/firebase/firebase-cpp-sdk/blob/edad366983e6f4e7d8a1c3823d95c48c791a8853/firestore/integration_test_internal/src/util/integration_test_util.cc#L25) the expression `sizeof(FirestoreInternal)` is `116`.
In contrast, in [firestore_android.cc](https://github.com/firebase/firebase-cpp-sdk/blob/edad366983e6f4e7d8a1c3823d95c48c791a8853/firestore/src/android/firestore_android.cc#L243) the expression `sizeof(FirestoreInternal)` is `128`.
Before `bundle_listeners_mutex_` and `bundle_listeners_` were added to `FirestoreInternal` in #394 the expression `sizeof(FirestoreInternal)` was `112`.
So we were basically getting lucky that the ODR caused *more* memory to be allocated by the call to `new FirestoreInternal(app)` than was needed; however, now that those two members were added to `FirestoreInternal` the `new FirestoreInternal(app)` call is allocating *fewer* bytes than needed, causing the initialization of `FirestoreInternal` to run off the end of its allocated memory.
The fix is to include the Android-specific header when building for Android, and the "common" header on non-Android.
Googlers can see b/192351260#comment13 for details.1 parent 9b1bd93 commit 0426070
File tree
1 file changed
+5
-0
lines changed- firestore/integration_test_internal/src/util
1 file changed
+5
-0
lines changedLines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
0 commit comments