1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Fix potential memory leaks in the misc 'compress' extension.

FossilOrigin-Name: 3bc34fd427d9d7819cd9740237b1f5d4180341fa
This commit is contained in:
mistachkin
2015-02-26 21:04:44 +00:00
parent 531b55ead0
commit 38e40ee2e5
3 changed files with 17 additions and 10 deletions

View File

@@ -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);
}
}