summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/lzma.c3
-rw-r--r--src/stream/rom_stream.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/lzma.c b/src/lib/lzma.c
index b46ddfcdae..dbaa805afa 100644
--- a/src/lib/lzma.c
+++ b/src/lib/lzma.c
@@ -28,16 +28,19 @@ static unsigned long ulzma(unsigned char * src, unsigned char * dst)
outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
printk_warning("Incorrect stream properties\n");
+ return 0;
}
mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
if (mallocneeds > 15980) {
printk_warning("Decoder scratchpad too small!\n");
+ return 0;
}
state.Probs = (CProb *)scratchpad;
res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
dst, outSize, &outProcessed);
if (res != 0) {
printk_warning("Decoding error = %d\n", res);
+ return 0;
}
return outSize;
}
diff --git a/src/stream/rom_stream.c b/src/stream/rom_stream.c
index 4386649c95..9357cf7e08 100644
--- a/src/stream/rom_stream.c
+++ b/src/stream/rom_stream.c
@@ -26,7 +26,7 @@ extern unsigned char _heap, _eheap;
#error "You're defining more than one compression type, which is not allowed (of course)"
#endif
#define HAVE_UNCOMPRESSER 1
-// include generic nrv2b
+// include generic lzma
#include "../lib/lzma.c"
#endif
@@ -97,8 +97,14 @@ int stream_init(void)
printk_debug("Uncompressing to RAM 0x%08lx ", dest);
olen = uncompress((uint8_t *) rom_start, (uint8_t *)dest );
printk_debug(" olen = 0x%08lx done.\n", olen);
- rom_end = dest + olen - 1;
- rom = dest;
+ if (olen != 0) {
+ rom_end = dest + olen - 1;
+ rom = dest;
+ } else {
+ /* Decompression failed, assume payload is uncompressed */
+ printk_debug("Decompression failed. Assuming payload is uncompressed...\n");
+ rom = rom_start;
+ }
#else
rom = rom_start;
#endif