Skip to content

Commit a4ef6c6

Browse files
committed
Merge branch 'StringFormatStringifySinkUseAfterFreeFix' into ThreadSafeMemoizerMemoryLeakFix
This PR is now based on #14306
2 parents 0f7dd55 + 24066f5 commit a4ef6c6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Firestore/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22
- [fixed] Fixed memory leak in `Query.whereField()`. (#13978)
3+
- [fixed] Fixed use-after-free bug when internally formatting strings. (#14306)
34

45
# 11.6.0
56
- [fixed] Add conditional `Sendable` conformance so `ServerTimestamp<T>` is

Firestore/core/test/unit/util/string_format_test.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Firestore/core/src/util/string_format.h"
1818

1919
#include "absl/strings/string_view.h"
20+
#include "gmock/gmock.h"
2021
#include "gtest/gtest.h"
2122

2223
namespace firebase {
@@ -72,14 +73,18 @@ TEST(StringFormatTest, Bool) {
7273
EXPECT_EQ("Hello false", StringFormat("Hello %s", false));
7374
}
7475

75-
TEST(StringFormatTest, Pointer) {
76-
// pointers implicitly convert to bool. Make sure this doesn't happen in
77-
// this API.
78-
int value = 4;
79-
EXPECT_NE("Hello true", StringFormat("Hello %s", &value));
76+
TEST(StringFormatTest, NullPointer) {
77+
// pointers implicitly convert to bool. Make sure this doesn't happen here.
8078
EXPECT_EQ("Hello null", StringFormat("Hello %s", nullptr));
8179
}
8280

81+
TEST(StringFormatTest, NonNullPointer) {
82+
// pointers implicitly convert to bool. Make sure this doesn't happen here.
83+
int value = 4;
84+
EXPECT_THAT(StringFormat("Hello %s", &value),
85+
testing::MatchesRegex("Hello (0x)?[0123456789abcdefABCDEF]+"));
86+
}
87+
8388
TEST(StringFormatTest, Mixed) {
8489
EXPECT_EQ("string=World, bool=true, int=42, float=1.5",
8590
StringFormat("string=%s, bool=%s, int=%s, float=%s", "World", true,

0 commit comments

Comments
 (0)