Check-in [5f36a86a73]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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).
Timelines: family | ancestors | descendants | both | memleak-fixes
Files: files | file ages | folders
SHA3-256: 5f36a86a73aef8bb5dc96439a3dfd970eceb76497198ea8639402b100068bc74
User & Date: stephan 2019-12-20 00:59:45.711
Context
2019-12-20
15:41
Removed the cleanup of g.zXYZ because there's simply too high of a chance that future changes would turn one of those free() calls into a double-free or passing an invalid pointer to free(). check-in: d60dd7afb0 user: stephan tags: memleak-fixes
00:59
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). check-in: 5f36a86a73 user: stephan tags: memleak-fixes
00:12
Various memleak fixes. Drops the reachable-at-exit memory of (fossil rebuild) on this repo from 45MB to 680kb. Added fossil_atexit_free_this() to allow us to clean up function-local static allocations. check-in: 00e6d7997c user: stephan tags: memleak-fixes
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407


408

409
410
411


412
413
414
415
416
417
418
419
  memset(&g.json, 0, sizeof(g.json));
#endif
  if(g.db){
    db_close(0);
  }
  fossil_free(g.ckinLockFail);
  fossil_free(g.zAuxSchema);
  fossil_free(g.zBaseURL);
  fossil_free(g.zConfigDbName);
  fossil_free(g.zErrMsg);
  fossil_free(g.zExtra);
  fossil_free(g.zHttpAuth);
  fossil_free(g.zHttpsURL);
  fossil_free(g.zIpAddr);
  fossil_free(g.zLocalDbName);
  fossil_free(g.zLocalRoot);
  fossil_free(g.zNonce);
  fossil_free(g.zOpenRevision);


  fossil_free(g.zPath);

  fossil_free(g.zRepositoryName);
  fossil_free(g.zRepositoryOption);
  fossil_free(g.zSshCmd);


  fossil_free(g.zTop);
  manifest_clear_cache();
  content_clear_cache(1);
  rebuild_clear_cache();
  if(fossilFreeAtExit.n>0){
    int i;
    for(i = 0; i < fossilFreeAtExit.n; ++i){
      fossil_free(fossilFreeAtExit.list[i]);







<


<

<




|
>
>
|
>
|
|
|
>
>
|







390
391
392
393
394
395
396

397
398

399

400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
  memset(&g.json, 0, sizeof(g.json));
#endif
  if(g.db){
    db_close(0);
  }
  fossil_free(g.ckinLockFail);
  fossil_free(g.zAuxSchema);

  fossil_free(g.zConfigDbName);
  fossil_free(g.zErrMsg);

  fossil_free(g.zHttpAuth);

  fossil_free(g.zIpAddr);
  fossil_free(g.zLocalDbName);
  fossil_free(g.zLocalRoot);
  fossil_free(g.zNonce);
  fossil_free(g.zSshCmd);
#define never_free(x)
  never_free(g.zTop/* sometimes part of another string */);
  never_free(g.zPath /* sometimes part of another string */);
  never_free(g.zBaseURL /* might be the same as g.zTop */);
  never_free(g.zRepositoryOption/* sometimes static */);
  never_free(g.zRepositoryName /* sometimes static */);
  never_free(g.zOpenRevision /* sometimes static */);
  never_free(g.zHttpsURL /* sometimes = g.zBaseUrl */);
  never_free(g.zExtra /* might be part of another string */);
#undef never_free
  manifest_clear_cache();
  content_clear_cache(1);
  rebuild_clear_cache();
  if(fossilFreeAtExit.n>0){
    int i;
    for(i = 0; i < fossilFreeAtExit.n; ++i){
      fossil_free(fossilFreeAtExit.list[i]);