| 1831 | } |
| 1832 | |
| 1833 | int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, |
| 1834 | const unsigned char *pSource, mz_ulong source_len) { |
| 1835 | mz_stream stream; |
| 1836 | int status; |
| 1837 | memset(&stream, 0, sizeof(stream)); |
| 1838 | |
| 1839 | // In case mz_ulong is 64-bits (argh I hate longs). |
| 1840 | if ((source_len | *pDest_len) > 0xFFFFFFFFU) |
| 1841 | return MZ_PARAM_ERROR; |
| 1842 | |
| 1843 | stream.next_in = pSource; |
| 1844 | stream.avail_in = (mz_uint32)source_len; |
| 1845 | stream.next_out = pDest; |
| 1846 | stream.avail_out = (mz_uint32)*pDest_len; |
| 1847 | |
| 1848 | status = mz_inflateInit(&stream); |
| 1849 | if (status != MZ_OK) |
| 1850 | return status; |
| 1851 | |
| 1852 | status = mz_inflate(&stream, MZ_FINISH); |
| 1853 | if (status != MZ_STREAM_END) { |
| 1854 | mz_inflateEnd(&stream); |
| 1855 | return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR |
| 1856 | : status; |
| 1857 | } |
| 1858 | *pDest_len = stream.total_out; |
| 1859 | |
| 1860 | return mz_inflateEnd(&stream); |
| 1861 | } |
| 1862 | |
| 1863 | const char *mz_error(int err) { |
| 1864 | static struct { |
no test coverage detected