commit | 71c498f7240c362c7312a5629b205c9dab5cd1ab | [log] [tgz] |
---|---|---|
author | Kazuhiro Inaba <kinaba@google.com> | Wed Aug 05 19:10:41 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Wed Aug 05 19:10:41 2020 +0000 |
tree | 107c6a4b0a828d6d509a0ffdced63dd88d88c72a | |
parent | e9fe87660b49b0f2e02963fbac07adcac2e7ae6b [diff] | |
parent | a3f91fc40b33d93093cd184a66cc49b45e5f9140 [diff] |
cts: Skip CtsInitTestCases over a native bridge. am: 9cecf8422a Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12263311 Change-Id: I9d208b96945f99b64da031d03e09a570862bcc1b
diff --git a/libutils/String8.cpp b/libutils/String8.cpp index d13548e..9d50e0b 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp
@@ -322,8 +322,14 @@ n = vsnprintf(nullptr, 0, fmt, tmp_args); va_end(tmp_args); - if (n != 0) { + if (n < 0) return UNKNOWN_ERROR; + + if (n > 0) { size_t oldLength = length(); + if ((size_t)n > SIZE_MAX - 1 || + oldLength > SIZE_MAX - (size_t)n - 1) { + return NO_MEMORY; + } char* buf = lockBuffer(oldLength + n); if (buf) { vsnprintf(buf + oldLength, n + 1, fmt, args);