commit | 1da481a21ea9e3ea9488d4f141139299b7ff8896 | [log] [tgz] |
---|---|---|
author | Alessio Balsini <balsini@google.com> | Mon Aug 10 19:10:37 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Mon Aug 10 19:10:37 2020 +0000 |
tree | 0bcc46884600e0eb0a7f432d6dee941f4192394a | |
parent | 71c498f7240c362c7312a5629b205c9dab5cd1ab [diff] | |
parent | fd73019503ebbb7fa5d48014d7a196ddf4726306 [diff] |
Re-enable libsnapshot ImageManagerTest am: c723fca056 Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12337395 Change-Id: Ic5cd924138f4dafeb238b4f2a0f6d7d5ffb7ea99
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);