Fossil SCM
Another simplification of SEE memory handling for the 'sql' command.
Commit
531434900bbc15a5325424085bcf20eb7decd1af755062cab07b4059b733e1c4
Parent
3b4a45535ed72a8…
1 file changed
+3
-5
+3
-5
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -284,25 +284,23 @@ | ||
| 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 | - size_t nByte; | |
| 290 | 289 | |
| 291 | 290 | if( zSavedKey==0 || savedKeySize==0 ) return; |
| 292 | - nByte = savedKeySize * sizeof(char); | |
| 293 | - zKey = (char*)malloc( nByte ); | |
| 291 | + zKey = (char*)malloc( savedKeySize ); | |
| 294 | 292 | if( zKey ){ |
| 295 | - memcpy(zKey, zSavedKey, nByte); | |
| 293 | + memcpy(zKey, zSavedKey, savedKeySize); | |
| 296 | 294 | *pzKey = zKey; |
| 297 | 295 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 298 | 296 | *pnKey = (int)strlen(zKey); |
| 299 | 297 | }else{ |
| 300 | 298 | *pnKey = -1; |
| 301 | 299 | } |
| 302 | 300 | }else{ |
| 303 | - fossil_fatal("failed to allocate %u bytes for key", nByte); | |
| 301 | + fossil_fatal("failed to allocate %u bytes for key", savedKeySize); | |
| 304 | 302 | } |
| 305 | 303 | } |
| 306 | 304 | #endif |
| 307 | 305 | |
| 308 | 306 | /* |
| 309 | 307 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -284,25 +284,23 @@ | |
| 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 | }else{ |
| 300 | *pnKey = -1; |
| 301 | } |
| 302 | }else{ |
| 303 | fossil_fatal("failed to allocate %u bytes for key", nByte); |
| 304 | } |
| 305 | } |
| 306 | #endif |
| 307 | |
| 308 | /* |
| 309 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -284,25 +284,23 @@ | |
| 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 | |
| 290 | if( zSavedKey==0 || savedKeySize==0 ) return; |
| 291 | zKey = (char*)malloc( savedKeySize ); |
| 292 | if( zKey ){ |
| 293 | memcpy(zKey, zSavedKey, savedKeySize); |
| 294 | *pzKey = zKey; |
| 295 | if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){ |
| 296 | *pnKey = (int)strlen(zKey); |
| 297 | }else{ |
| 298 | *pnKey = -1; |
| 299 | } |
| 300 | }else{ |
| 301 | fossil_fatal("failed to allocate %u bytes for key", savedKeySize); |
| 302 | } |
| 303 | } |
| 304 | #endif |
| 305 | |
| 306 | /* |
| 307 |