lzo: Update dst_len even on error
authorSimon Glass <sjg@chromium.org>
Tue, 2 Dec 2014 20:17:40 +0000 (13:17 -0700)
committerTom Rini <trini@ti.com>
Wed, 14 Jan 2015 16:35:44 +0000 (11:35 -0500)
This allows the caller to easily detect how much of the destination buffer
has been used.

Signed-off-by: Simon Glass <sjg@chromium.org>
lib/lzo/lzo1x_decompress.c

index 35f3793f31c61e045df3c634b5299d7c735fc623..ebdf10b988de5964bb7769f2433ab91d8d99bffa 100644 (file)
@@ -102,8 +102,10 @@ int lzop_decompress(const unsigned char *src, size_t src_len,
                tmp = dlen;
                r = lzo1x_decompress_safe((u8 *) src, slen, dst, &tmp);
 
-               if (r != LZO_E_OK)
+               if (r != LZO_E_OK) {
+                       *dst_len = dst - start;
                        return r;
+               }
 
                if (dlen != tmp)
                        return LZO_E_ERROR;