Fossil SCM

atexit: no longer freeing about half of g.zXYZ because they're not always safe to free (sometimes they point to each other or are substrings of other strings).

stephan 2019-12-20 00:59 memleak-fixes
Commit 5f36a86a73aef8bb5dc96439a3dfd970eceb76497198ea8639402b100068bc74
1 file changed +10 -8
+10 -8
--- src/main.c
+++ src/main.c
@@ -392,26 +392,28 @@
392392
if(g.db){
393393
db_close(0);
394394
}
395395
fossil_free(g.ckinLockFail);
396396
fossil_free(g.zAuxSchema);
397
- fossil_free(g.zBaseURL);
398397
fossil_free(g.zConfigDbName);
399398
fossil_free(g.zErrMsg);
400
- fossil_free(g.zExtra);
401399
fossil_free(g.zHttpAuth);
402
- fossil_free(g.zHttpsURL);
403400
fossil_free(g.zIpAddr);
404401
fossil_free(g.zLocalDbName);
405402
fossil_free(g.zLocalRoot);
406403
fossil_free(g.zNonce);
407
- fossil_free(g.zOpenRevision);
408
- fossil_free(g.zPath);
409
- fossil_free(g.zRepositoryName);
410
- fossil_free(g.zRepositoryOption);
411404
fossil_free(g.zSshCmd);
412
- fossil_free(g.zTop);
405
+#define never_free(x)
406
+ never_free(g.zTop/* sometimes part of another string */);
407
+ never_free(g.zPath /* sometimes part of another string */);
408
+ never_free(g.zBaseURL /* might be the same as g.zTop */);
409
+ never_free(g.zRepositoryOption/* sometimes static */);
410
+ never_free(g.zRepositoryName /* sometimes static */);
411
+ never_free(g.zOpenRevision /* sometimes static */);
412
+ never_free(g.zHttpsURL /* sometimes = g.zBaseUrl */);
413
+ never_free(g.zExtra /* might be part of another string */);
414
+#undef never_free
413415
manifest_clear_cache();
414416
content_clear_cache(1);
415417
rebuild_clear_cache();
416418
if(fossilFreeAtExit.n>0){
417419
int i;
418420
--- src/main.c
+++ src/main.c
@@ -392,26 +392,28 @@
392 if(g.db){
393 db_close(0);
394 }
395 fossil_free(g.ckinLockFail);
396 fossil_free(g.zAuxSchema);
397 fossil_free(g.zBaseURL);
398 fossil_free(g.zConfigDbName);
399 fossil_free(g.zErrMsg);
400 fossil_free(g.zExtra);
401 fossil_free(g.zHttpAuth);
402 fossil_free(g.zHttpsURL);
403 fossil_free(g.zIpAddr);
404 fossil_free(g.zLocalDbName);
405 fossil_free(g.zLocalRoot);
406 fossil_free(g.zNonce);
407 fossil_free(g.zOpenRevision);
408 fossil_free(g.zPath);
409 fossil_free(g.zRepositoryName);
410 fossil_free(g.zRepositoryOption);
411 fossil_free(g.zSshCmd);
412 fossil_free(g.zTop);
 
 
 
 
 
 
 
 
 
413 manifest_clear_cache();
414 content_clear_cache(1);
415 rebuild_clear_cache();
416 if(fossilFreeAtExit.n>0){
417 int i;
418
--- src/main.c
+++ src/main.c
@@ -392,26 +392,28 @@
392 if(g.db){
393 db_close(0);
394 }
395 fossil_free(g.ckinLockFail);
396 fossil_free(g.zAuxSchema);
 
397 fossil_free(g.zConfigDbName);
398 fossil_free(g.zErrMsg);
 
399 fossil_free(g.zHttpAuth);
 
400 fossil_free(g.zIpAddr);
401 fossil_free(g.zLocalDbName);
402 fossil_free(g.zLocalRoot);
403 fossil_free(g.zNonce);
 
 
 
 
404 fossil_free(g.zSshCmd);
405 #define never_free(x)
406 never_free(g.zTop/* sometimes part of another string */);
407 never_free(g.zPath /* sometimes part of another string */);
408 never_free(g.zBaseURL /* might be the same as g.zTop */);
409 never_free(g.zRepositoryOption/* sometimes static */);
410 never_free(g.zRepositoryName /* sometimes static */);
411 never_free(g.zOpenRevision /* sometimes static */);
412 never_free(g.zHttpsURL /* sometimes = g.zBaseUrl */);
413 never_free(g.zExtra /* might be part of another string */);
414 #undef never_free
415 manifest_clear_cache();
416 content_clear_cache(1);
417 rebuild_clear_cache();
418 if(fossilFreeAtExit.n>0){
419 int i;
420

Keyboard Shortcuts

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