Skip to content

Commit 128f215

Browse files
authored
Merge pull request #124 from google/oss_fixes
strings: fix invalid access with UTF8 verification, ensure absl::string_view compatibility
2 parents ebcffc2 + db9e3fa commit 128f215

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

base/unilib.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ namespace UniLib {
66

77
// Detects whether a string is valid UTF-8.
88
bool IsStructurallyValid(absl::string_view str) {
9+
if (str.size() == 0) {
10+
return true;
11+
}
912
const char *s = &str[0];
1013
const char *const sEnd = s + str.length();
1114
while (s < sEnd) {

bazel/abseil.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Force internal versions of std classes per
2+
# https://abseil.io/docs/cpp/guides/options
3+
diff --git a/absl/base/options.h b/absl/base/options.h
4+
index 230bf1e..6e1b9e5 100644
5+
--- a/absl/base/options.h
6+
+++ b/absl/base/options.h
7+
@@ -100,7 +100,7 @@
8+
// User code should not inspect this macro. To check in the preprocessor if
9+
// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.
10+
11+
-#define ABSL_OPTION_USE_STD_ANY 2
12+
+#define ABSL_OPTION_USE_STD_ANY 0
13+
14+
15+
// ABSL_OPTION_USE_STD_OPTIONAL
16+
@@ -127,7 +127,7 @@
17+
// absl::optional is a typedef of std::optional, use the feature macro
18+
// ABSL_USES_STD_OPTIONAL.
19+
20+
-#define ABSL_OPTION_USE_STD_OPTIONAL 2
21+
+#define ABSL_OPTION_USE_STD_OPTIONAL 0
22+
23+
24+
// ABSL_OPTION_USE_STD_STRING_VIEW
25+
@@ -154,7 +154,7 @@
26+
// absl::string_view is a typedef of std::string_view, use the feature macro
27+
// ABSL_USES_STD_STRING_VIEW.
28+
29+
-#define ABSL_OPTION_USE_STD_STRING_VIEW 2
30+
+#define ABSL_OPTION_USE_STD_STRING_VIEW 0
31+
32+
// ABSL_OPTION_USE_STD_VARIANT
33+
//
34+
@@ -180,7 +180,7 @@
35+
// absl::variant is a typedef of std::variant, use the feature macro
36+
// ABSL_USES_STD_VARIANT.
37+
38+
-#define ABSL_OPTION_USE_STD_VARIANT 2
39+
+#define ABSL_OPTION_USE_STD_VARIANT 0
40+
41+
42+
// ABSL_OPTION_USE_INLINE_NAMESPACE

bazel/deps.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def base_deps():
88
"""Base evaluator and test dependencies."""
99
http_archive(
1010
name = "com_google_absl",
11+
patches = ["//bazel:abseil.patch"],
12+
patch_args = ["-p1"],
1113
strip_prefix = "abseil-cpp-master",
1214
urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
1315
)

eval/public/structs/cel_proto_wrapper.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue
548548
if (!result.has_value()) {
549549
return {};
550550
}
551-
(*fields)[key] = field_value;
551+
(*fields)[std::string(key)] = field_value;
552552
}
553553
return json_struct;
554554
}

0 commit comments

Comments
 (0)