Index: third_party/sqlite/src/ext/misc/compress.c |
diff --git a/third_party/sqlite/src/ext/misc/compress.c b/third_party/sqlite/src/ext/misc/compress.c |
index a4059116c9e4c981b1345fca9bb9c0edf35dcb4b..bf38d4c93cfeff2785c2bf6ff523e6f745d3a113 100644 |
--- a/third_party/sqlite/src/ext/misc/compress.c |
+++ b/third_party/sqlite/src/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); |
} |
} |