Fossil SCM
Eliminate a superfluous allocation and have freepass() zero out its storage to avoid a duplicate free() in the very off chance that it's ever called twice. These are cleanups made in passing, not fixing known problems.
Commit
1c9d5cd81dd0531e146e18147644766e93ddad88ea6427371c29ec710874cd24
Parent
4bb41f924263e2e…
1 file changed
+4
-3
+4
-3
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -109,10 +109,12 @@ | ||
| 109 | 109 | } |
| 110 | 110 | void freepass(){ |
| 111 | 111 | if( !zPwdBuffer ) return; |
| 112 | 112 | assert( nPwdBuffer>0 ); |
| 113 | 113 | fossil_secure_free_page(zPwdBuffer, nPwdBuffer); |
| 114 | + zPwdBuffer = 0; | |
| 115 | + nPwdBuffer = 0; | |
| 114 | 116 | } |
| 115 | 117 | #endif |
| 116 | 118 | |
| 117 | 119 | /* |
| 118 | 120 | ** Scramble substitution matrix: |
| @@ -286,13 +288,12 @@ | ||
| 286 | 288 | char *zPrompt = mprintf("\rpassword for %s: ", zUser); |
| 287 | 289 | char *zPw; |
| 288 | 290 | Blob x; |
| 289 | 291 | fossil_force_newline(); |
| 290 | 292 | prompt_for_password(zPrompt, &x, 0); |
| 291 | - free(zPrompt); | |
| 292 | - zPw = mprintf("%b", &x); | |
| 293 | - blob_reset(&x); | |
| 293 | + fossil_free(zPrompt); | |
| 294 | + zPw = blob_str(&x)/*transfer ownership*/; | |
| 294 | 295 | return zPw; |
| 295 | 296 | } |
| 296 | 297 | |
| 297 | 298 | /* |
| 298 | 299 | ** Prompt the user to enter a single line of text. |
| 299 | 300 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -109,10 +109,12 @@ | |
| 109 | } |
| 110 | void freepass(){ |
| 111 | if( !zPwdBuffer ) return; |
| 112 | assert( nPwdBuffer>0 ); |
| 113 | fossil_secure_free_page(zPwdBuffer, nPwdBuffer); |
| 114 | } |
| 115 | #endif |
| 116 | |
| 117 | /* |
| 118 | ** Scramble substitution matrix: |
| @@ -286,13 +288,12 @@ | |
| 286 | char *zPrompt = mprintf("\rpassword for %s: ", zUser); |
| 287 | char *zPw; |
| 288 | Blob x; |
| 289 | fossil_force_newline(); |
| 290 | prompt_for_password(zPrompt, &x, 0); |
| 291 | free(zPrompt); |
| 292 | zPw = mprintf("%b", &x); |
| 293 | blob_reset(&x); |
| 294 | return zPw; |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | ** Prompt the user to enter a single line of text. |
| 299 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -109,10 +109,12 @@ | |
| 109 | } |
| 110 | void freepass(){ |
| 111 | if( !zPwdBuffer ) return; |
| 112 | assert( nPwdBuffer>0 ); |
| 113 | fossil_secure_free_page(zPwdBuffer, nPwdBuffer); |
| 114 | zPwdBuffer = 0; |
| 115 | nPwdBuffer = 0; |
| 116 | } |
| 117 | #endif |
| 118 | |
| 119 | /* |
| 120 | ** Scramble substitution matrix: |
| @@ -286,13 +288,12 @@ | |
| 288 | char *zPrompt = mprintf("\rpassword for %s: ", zUser); |
| 289 | char *zPw; |
| 290 | Blob x; |
| 291 | fossil_force_newline(); |
| 292 | prompt_for_password(zPrompt, &x, 0); |
| 293 | fossil_free(zPrompt); |
| 294 | zPw = blob_str(&x)/*transfer ownership*/; |
| 295 | return zPw; |
| 296 | } |
| 297 | |
| 298 | /* |
| 299 | ** Prompt the user to enter a single line of text. |
| 300 |