Fossil SCM
Correction to SEE memory handling used by the 'sql' command.
Commit
3b4a45535ed72a879c811c607a65dd348a7d5aa09f4892d9a7bc464b03234c9d
Parent
5e2dbcc6fe611bf…
1 file changed
+2
-2
+2
-2
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -278,21 +278,21 @@ | ||
| 278 | 278 | |
| 279 | 279 | #if USE_SEE |
| 280 | 280 | /* |
| 281 | 281 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 282 | 282 | ** to load the encryption key for the open Fossil database. The memory that |
| 283 | -** is pointed to by the value placed in pzKey must be obtained from SQLite. | |
| 283 | +** is pointed to by the value placed in pzKey must be obtained from malloc. | |
| 284 | 284 | */ |
| 285 | 285 | void fossil_key(const char **pzKey, int *pnKey){ |
| 286 | 286 | char *zSavedKey = db_get_saved_encryption_key(); |
| 287 | 287 | char *zKey; |
| 288 | 288 | size_t savedKeySize = db_get_saved_encryption_key_size(); |
| 289 | 289 | size_t nByte; |
| 290 | 290 | |
| 291 | 291 | if( zSavedKey==0 || savedKeySize==0 ) return; |
| 292 | 292 | nByte = savedKeySize * sizeof(char); |
| 293 | - zKey = sqlite3_malloc( (int)nByte ); | |
| 293 | + zKey = (char*)malloc( nByte ); | |
| 294 | 294 | if( zKey ){ |
| 295 | 295 | memcpy(zKey, zSavedKey, nByte); |
| 296 | 296 | *pzKey = zKey; |
| 297 | 297 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 298 | 298 | *pnKey = (int)strlen(zKey); |
| 299 | 299 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -278,21 +278,21 @@ | |
| 278 | |
| 279 | #if USE_SEE |
| 280 | /* |
| 281 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 282 | ** to load the encryption key for the open Fossil database. The memory that |
| 283 | ** is pointed to by the value placed in pzKey must be obtained from SQLite. |
| 284 | */ |
| 285 | void fossil_key(const char **pzKey, int *pnKey){ |
| 286 | char *zSavedKey = db_get_saved_encryption_key(); |
| 287 | char *zKey; |
| 288 | size_t savedKeySize = db_get_saved_encryption_key_size(); |
| 289 | size_t nByte; |
| 290 | |
| 291 | if( zSavedKey==0 || savedKeySize==0 ) return; |
| 292 | nByte = savedKeySize * sizeof(char); |
| 293 | zKey = sqlite3_malloc( (int)nByte ); |
| 294 | if( zKey ){ |
| 295 | memcpy(zKey, zSavedKey, nByte); |
| 296 | *pzKey = zKey; |
| 297 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 298 | *pnKey = (int)strlen(zKey); |
| 299 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -278,21 +278,21 @@ | |
| 278 | |
| 279 | #if USE_SEE |
| 280 | /* |
| 281 | ** This routine is called by the patched sqlite3 command-line shell in order |
| 282 | ** to load the encryption key for the open Fossil database. The memory that |
| 283 | ** is pointed to by the value placed in pzKey must be obtained from malloc. |
| 284 | */ |
| 285 | void fossil_key(const char **pzKey, int *pnKey){ |
| 286 | char *zSavedKey = db_get_saved_encryption_key(); |
| 287 | char *zKey; |
| 288 | size_t savedKeySize = db_get_saved_encryption_key_size(); |
| 289 | size_t nByte; |
| 290 | |
| 291 | if( zSavedKey==0 || savedKeySize==0 ) return; |
| 292 | nByte = savedKeySize * sizeof(char); |
| 293 | zKey = (char*)malloc( nByte ); |
| 294 | if( zKey ){ |
| 295 | memcpy(zKey, zSavedKey, nByte); |
| 296 | *pzKey = zKey; |
| 297 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 298 | *pnKey = (int)strlen(zKey); |
| 299 |