From: mistachkin Date: Thu, 26 Feb 2015 21:04:44 +0000 (+0000) Subject: Fix potential memory leaks in the misc 'compress' extension. X-Git-Tag: version-3.8.9~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38e40ee2e5e4960bd5c7247018da08b018f1b552;p=thirdparty%2Fsqlite.git Fix potential memory leaks in the misc 'compress' extension. FossilOrigin-Name: 3bc34fd427d9d7819cd9740237b1f5d4180341fa --- diff --git a/ext/misc/compress.c b/ext/misc/compress.c index a4059116c9..bf38d4c93c 100644 --- a/ext/misc/compress.c +++ b/ext/misc/compress.c @@ -38,6 +38,7 @@ static void compressFunc( unsigned int nIn; unsigned long int nOut; unsigned char x[8]; + int rc; int i, j; pIn = sqlite3_value_blob(argv[0]); @@ -50,8 +51,12 @@ static void compressFunc( for(i=0; i<4 && x[i]==0; i++){} for(j=0; i<=4; i++, j++) pOut[j] = x[i]; pOut[j-1] |= 0x80; - compress(&pOut[j], &nOut, pIn, nIn); - sqlite3_result_blob(context, pOut, nOut+j, sqlite3_free); + rc = compress(&pOut[j], &nOut, pIn, nIn); + if( rc==Z_OK ){ + sqlite3_result_blob(context, pOut, nOut+j, sqlite3_free); + }else{ + sqlite3_free(pOut); + } } /* @@ -82,6 +87,8 @@ static void uncompressFunc( rc = uncompress(pOut, &nOut, &pIn[i], nIn-i); if( rc==Z_OK ){ sqlite3_result_blob(context, pOut, nOut, sqlite3_free); + }else{ + sqlite3_free(pOut); } } diff --git a/manifest b/manifest index bb17e20589..c2419455e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\srequirements\smark\sto\sreflect\sa\schange\sof\swording\sin\sthe\sdocumentation.\nNo\schanges\sto\scode. -D 2015-02-26T16:40:41.460 +C Fix\spotential\smemory\sleaks\sin\sthe\smisc\s'compress'\sextension. +D 2015-02-26T21:04:44.709 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 6b9e7677829aa94b9f30949656e27312aefb9a46 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -108,7 +108,7 @@ F ext/icu/icu.c d415ccf984defeb9df2c0e1afcfaa2f6dc05eacb F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/misc/amatch.c 27b9b601fb1453084e18a3432ea0240d7af8decb F ext/misc/closure.c 636024302cde41b2bf0c542f81c40c624cfb7012 -F ext/misc/compress.c 76e45655f4046e756064ab10c62e18f2eb846b9f +F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c e3e18f47252c151b5553d7e806f38e757d37c4cc @@ -1239,7 +1239,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a62ba58c737656fae620d9cdaaae299104ac06f6 -R 10478383687ae87f2012aeaa926b3297 -U drh -Z ebf66855f11c3f65a39c6b4bb93adf68 +P 3038d0169bfc3f63d64c7fef20ab2323d032655f +R 92275b863621a447a1ee2bc5287be291 +U mistachkin +Z 13fe93e6bf28cbbfddb5268264090ce6 diff --git a/manifest.uuid b/manifest.uuid index 001a5cd348..a8a6350637 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3038d0169bfc3f63d64c7fef20ab2323d032655f \ No newline at end of file +3bc34fd427d9d7819cd9740237b1f5d4180341fa \ No newline at end of file