Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix potential memory leaks in the misc 'compress' extension. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3bc34fd427d9d7819cd9740237b1f5d4 |
User & Date: | mistachkin 2015-02-26 21:04:44.709 |
Context
2015-02-27
| ||
00:33 | Add a couple of requirements marks. (check-in: d70b0fd4c9 user: drh tags: trunk) | |
2015-02-26
| ||
21:04 | Fix potential memory leaks in the misc 'compress' extension. (check-in: 3bc34fd427 user: mistachkin tags: trunk) | |
16:40 | Update a requirements mark to reflect a change of wording in the documentation. No changes to code. (check-in: 3038d0169b user: drh tags: trunk) | |
Changes
Changes to ext/misc/compress.c.
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | sqlite3_value **argv ){ const unsigned char *pIn; unsigned char *pOut; unsigned int nIn; unsigned long int nOut; unsigned char x[8]; int i, j; pIn = sqlite3_value_blob(argv[0]); nIn = sqlite3_value_bytes(argv[0]); nOut = 13 + nIn + (nIn+999)/1000; pOut = sqlite3_malloc( nOut+5 ); for(i=4; i>=0; i--){ x[i] = (nIn >> (7*(4-i)))&0x7f; } for(i=0; i<4 && x[i]==0; i++){} for(j=0; i<=4; i++, j++) pOut[j] = x[i]; pOut[j-1] |= 0x80; | > | > | > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | sqlite3_value **argv ){ const unsigned char *pIn; unsigned char *pOut; unsigned int nIn; unsigned long int nOut; unsigned char x[8]; int rc; int i, j; pIn = sqlite3_value_blob(argv[0]); nIn = sqlite3_value_bytes(argv[0]); nOut = 13 + nIn + (nIn+999)/1000; pOut = sqlite3_malloc( nOut+5 ); for(i=4; i>=0; i--){ x[i] = (nIn >> (7*(4-i)))&0x7f; } for(i=0; i<4 && x[i]==0; i++){} for(j=0; i<=4; i++, j++) pOut[j] = x[i]; pOut[j-1] |= 0x80; rc = compress(&pOut[j], &nOut, pIn, nIn); if( rc==Z_OK ){ sqlite3_result_blob(context, pOut, nOut+j, sqlite3_free); }else{ sqlite3_free(pOut); } } /* ** Implementation of the "uncompress(X)" SQL function. The argument X ** is a blob which was obtained from compress(Y). The output will be ** the value Y. */ |
︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | nOut = (nOut<<7) | (pIn[i]&0x7f); if( (pIn[i]&0x80)!=0 ){ i++; break; } } pOut = sqlite3_malloc( nOut+1 ); rc = uncompress(pOut, &nOut, &pIn[i], nIn-i); if( rc==Z_OK ){ sqlite3_result_blob(context, pOut, nOut, sqlite3_free); } } #ifdef _WIN32 __declspec(dllexport) #endif | > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | nOut = (nOut<<7) | (pIn[i]&0x7f); if( (pIn[i]&0x80)!=0 ){ i++; break; } } pOut = sqlite3_malloc( nOut+1 ); rc = uncompress(pOut, &nOut, &pIn[i], nIn-i); if( rc==Z_OK ){ sqlite3_result_blob(context, pOut, nOut, sqlite3_free); }else{ sqlite3_free(pOut); } } #ifdef _WIN32 __declspec(dllexport) #endif |
︙ | ︙ |