Fossil SCM
Do not free memory not obtained from malloc in the "fossil diff" command. Ticket [38d7bb8cf044219c2eff8].
Commit
ddb975e2be4c1339c189b96eefe3b28cabf90aaf
Parent
23a3adac3937b26…
1 file changed
+2
-1
+2
-1
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -253,10 +253,11 @@ | ||
| 253 | 253 | int isDeleted = db_column_int(&q, 1); |
| 254 | 254 | int isChnged = db_column_int(&q,2); |
| 255 | 255 | int isNew = db_column_int(&q,3); |
| 256 | 256 | int srcid = db_column_int(&q, 4); |
| 257 | 257 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 258 | + char *zToFree = zFullName; | |
| 258 | 259 | int showDiff = 1; |
| 259 | 260 | if( isDeleted ){ |
| 260 | 261 | printf("DELETED %s\n", zPathname); |
| 261 | 262 | if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; } |
| 262 | 263 | }else if( access(zFullName, 0) ){ |
| @@ -283,11 +284,11 @@ | ||
| 283 | 284 | zPathname |
| 284 | 285 | ); |
| 285 | 286 | diff_file(&content, zFullName, zPathname, zDiffCmd, ignoreEolWs); |
| 286 | 287 | blob_reset(&content); |
| 287 | 288 | } |
| 288 | - free(zFullName); | |
| 289 | + free(zToFree); | |
| 289 | 290 | } |
| 290 | 291 | db_finalize(&q); |
| 291 | 292 | db_end_transaction(1); /* ROLLBACK */ |
| 292 | 293 | } |
| 293 | 294 | |
| 294 | 295 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -253,10 +253,11 @@ | |
| 253 | int isDeleted = db_column_int(&q, 1); |
| 254 | int isChnged = db_column_int(&q,2); |
| 255 | int isNew = db_column_int(&q,3); |
| 256 | int srcid = db_column_int(&q, 4); |
| 257 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 258 | int showDiff = 1; |
| 259 | if( isDeleted ){ |
| 260 | printf("DELETED %s\n", zPathname); |
| 261 | if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; } |
| 262 | }else if( access(zFullName, 0) ){ |
| @@ -283,11 +284,11 @@ | |
| 283 | zPathname |
| 284 | ); |
| 285 | diff_file(&content, zFullName, zPathname, zDiffCmd, ignoreEolWs); |
| 286 | blob_reset(&content); |
| 287 | } |
| 288 | free(zFullName); |
| 289 | } |
| 290 | db_finalize(&q); |
| 291 | db_end_transaction(1); /* ROLLBACK */ |
| 292 | } |
| 293 | |
| 294 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -253,10 +253,11 @@ | |
| 253 | int isDeleted = db_column_int(&q, 1); |
| 254 | int isChnged = db_column_int(&q,2); |
| 255 | int isNew = db_column_int(&q,3); |
| 256 | int srcid = db_column_int(&q, 4); |
| 257 | char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 258 | char *zToFree = zFullName; |
| 259 | int showDiff = 1; |
| 260 | if( isDeleted ){ |
| 261 | printf("DELETED %s\n", zPathname); |
| 262 | if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; } |
| 263 | }else if( access(zFullName, 0) ){ |
| @@ -283,11 +284,11 @@ | |
| 284 | zPathname |
| 285 | ); |
| 286 | diff_file(&content, zFullName, zPathname, zDiffCmd, ignoreEolWs); |
| 287 | blob_reset(&content); |
| 288 | } |
| 289 | free(zToFree); |
| 290 | } |
| 291 | db_finalize(&q); |
| 292 | db_end_transaction(1); /* ROLLBACK */ |
| 293 | } |
| 294 | |
| 295 |