Fossil SCM

Correction to SEE memory handling used by the 'sql' command.

mistachkin 2021-12-29 14:34 trunk
Commit 3b4a45535ed72a879c811c607a65dd348a7d5aa09f4892d9a7bc464b03234c9d
1 file changed +2 -2
+2 -2
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -278,21 +278,21 @@
278278
279279
#if USE_SEE
280280
/*
281281
** This routine is called by the patched sqlite3 command-line shell in order
282282
** 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.
284284
*/
285285
void fossil_key(const char **pzKey, int *pnKey){
286286
char *zSavedKey = db_get_saved_encryption_key();
287287
char *zKey;
288288
size_t savedKeySize = db_get_saved_encryption_key_size();
289289
size_t nByte;
290290
291291
if( zSavedKey==0 || savedKeySize==0 ) return;
292292
nByte = savedKeySize * sizeof(char);
293
- zKey = sqlite3_malloc( (int)nByte );
293
+ zKey = (char*)malloc( nByte );
294294
if( zKey ){
295295
memcpy(zKey, zSavedKey, nByte);
296296
*pzKey = zKey;
297297
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
298298
*pnKey = (int)strlen(zKey);
299299
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button