diff options
| author | 2015-01-27 23:02:57 +0000 | |
|---|---|---|
| committer | 2015-01-27 23:02:57 +0000 | |
| commit | 714b6517dcca03a1a6496b33064d54a6b781914a (patch) | |
| tree | 185f267009000dd783fd409a12465f50f8799dc1 | |
| parent | f5386a9a949297be1321cce7eed5d0975c7b64ad (diff) | |
| parent | cae216f8dc3e1d752f2c353e488da07cadd95570 (diff) | |
am cae216f8: am 1e0d4b56: am 1dbbc204: am 6106f6a4: am 93522968: am 01287549: am 9a6143fa: Handle bad ninepatch data.
* commit 'cae216f8dc3e1d752f2c353e488da07cadd95570':
Handle bad ninepatch data.
| -rw-r--r-- | core/jni/android/graphics/NinePatchPeeker.cpp | 4 | ||||
| -rw-r--r-- | include/androidfw/ResourceTypes.h | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/core/jni/android/graphics/NinePatchPeeker.cpp b/core/jni/android/graphics/NinePatchPeeker.cpp index 1dafa1b5397d..d99ddeb9bfc1 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) && 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 ac5eca08a4ff..07df5ae00252 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -107,9 +107,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 |