summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins III <scroggo@google.com> 2015-01-27 22:31:47 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-01-27 22:31:47 +0000
commit6106f6a490cb5816602e8e3ae84a5c653dda44d3 (patch)
tree858cb7024d4154aa4fd176ae7d55f6a10056fe00
parent8505c3870a17f41d23329344fe381cd9ff324bd2 (diff)
parent9352296810926eae663477526545a55e1b1f7a27 (diff)
am 93522968: am 01287549: am 9a6143fa: Handle bad ninepatch data.
* commit '9352296810926eae663477526545a55e1b1f7a27': 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 d3482da34fa2..077442e19895 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 97afa59bd7cd..be7923c0a0ac 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -107,9 +107,9 @@ struct Res_png_9patch
yDivs(NULL), colors(NULL) { }
int8_t wasDeserialized;
- int8_t numXDivs;
- int8_t numYDivs;
- int8_t numColors;
+ uint8_t numXDivs;
+ uint8_t numYDivs;
+ uint8_t numColors;
// These tell where the next section of a patch starts.
// For example, the first patch includes the pixels from