summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2015-01-28 17:39:52 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-01-28 17:39:52 +0000
commit5d7bd13fc88d066d4c27a2459f3e3a58a1f4dec2 (patch)
tree74b467e96486f4d1d4d7d734a24bf082addaebbd
parenteada048addc14a95ced54b17c6a75f5f899e2c2a (diff)
parent1e0d4b5611f9a7134c9ab5fdb62b9385c5161c7c (diff)
downloadframeworks_base-5d7bd13fc88d066d4c27a2459f3e3a58a1f4dec2.zip
frameworks_base-5d7bd13fc88d066d4c27a2459f3e3a58a1f4dec2.tar.gz
frameworks_base-5d7bd13fc88d066d4c27a2459f3e3a58a1f4dec2.tar.bz2
am 1dbbc204: am 6106f6a4: am 93522968: am 01287549: am 9a6143fa: Handle bad ninepatch data.
automerge: 1e0d4b5 * commit '1e0d4b5611f9a7134c9ab5fdb62b9385c5161c7c': Handle bad ninepatch data.
-rw-r--r--core/jni/android/graphics/NinePatchPeeker.cpp4
-rw-r--r--include/androidfw/ResourceTypes.h6
2 files changed, 6 insertions, 4 deletions
diff --git a/core/jni/android/graphics/NinePatchPeeker.cpp b/core/jni/android/graphics/NinePatchPeeker.cpp
index 5daa1ad..184bc7b 100644
--- a/core/jni/android/graphics/NinePatchPeeker.cpp
+++ b/core/jni/android/graphics/NinePatchPeeker.cpp
@@ -24,7 +24,9 @@ bool NinePatchPeeker::peek(const char tag[], const void* data, size_t length) {
if (strcmp("npTc", tag) == 0 && length >= sizeof(Res_png_9patch)) {
Res_png_9patch* patch = (Res_png_9patch*) data;
size_t patchSize = patch->serializedSize();
- assert(length == patchSize);
+ if (length != patchSize) {
+ return false;
+ }
// You have to copy the data because it is owned by the png reader
Res_png_9patch* patchNew = (Res_png_9patch*) malloc(patchSize);
memcpy(patchNew, patch, patchSize);
diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h
index 2306a7a..8369c11 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -106,9 +106,9 @@ struct Res_png_9patch
yDivsOffset(0), colorsOffset(0) { }
int8_t wasDeserialized;
- int8_t numXDivs;
- int8_t numYDivs;
- int8_t numColors;
+ uint8_t numXDivs;
+ uint8_t numYDivs;
+ uint8_t numColors;
// The offset (from the start of this structure) to the xDivs & yDivs
// array for this 9patch. To get a pointer to this array, call