Skip to content

Commit 4677ba7

Browse files
jonsimantova-maurice
authored andcommitted
Fix a broken test caused by a small issue in auth.cc unregistering listeners, which failed on some platforms because the copy/move constructor couldn't handle src/dest being the same.
PiperOrigin-RevId: 253662165
1 parent 03c4cfa commit 4677ba7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

auth/src/auth.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include "auth/src/include/firebase/auth.h"
18+
1719
#include <assert.h>
1820
#include <stdio.h>
21+
1922
#include <algorithm>
2023
#include <cstdint>
2124
#include <map>
@@ -32,7 +35,6 @@
3235
#include "app/src/util.h"
3336
#include "auth/src/common.h"
3437
#include "auth/src/data.h"
35-
#include "auth/src/include/firebase/auth.h"
3638

3739
// Workaround MSVC's incompatible libc headers.
3840
#ifdef _WIN32
@@ -242,12 +244,14 @@ static bool ReplaceEntryWithBack(const T& entry, std::vector<T>* v) {
242244
auto it = std::find(v->begin(), v->end(), entry);
243245
if (it == v->end()) return false;
244246

247+
// If it's not already the back element, move/copy the back element onto it.
248+
if (&(*it) != &(v->back())) {
245249
#if defined(FIREBASE_USE_MOVE_OPERATORS)
246-
*it = std::move(v->back());
250+
*it = std::move(v->back());
247251
#else
248-
*it = v->back();
252+
*it = v->back();
249253
#endif // defined(FIREBASE_USE_MOVE_OPERATORS)
250-
254+
}
251255
v->pop_back();
252256
return true;
253257
}

0 commit comments

Comments
 (0)