Fossil

Check-in [252ca35f47]
Login

Check-in [252ca35f47]

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

Overview
Comment:Clean up g.non-const zXYZ members in the atexit handler. Add a blob_reset() in finish_tag() to cover the case that fast_insert_content() does not reset it.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | memleak-fixes
Files: files | file ages | folders
SHA3-256: 252ca35f47a91f27846926f99362a376aae3d392e77236df3a15fd7f5bb4d8db
User & Date: stephan 2019-12-19 20:41:30.348
Context
2019-12-20
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)
2019-12-19
20:41
Clean up g.non-const zXYZ members in the atexit handler. Add a blob_reset() in finish_tag() to cover the case that fast_insert_content() does not reset it. ... (check-in: 252ca35f47 user: stephan tags: memleak-fixes)
18:54
Several memleak fixes reported via https://fossil-scm.org/forum/forumpost/205b004d8a. In a branch so the OP can test them in his setup. ... (check-in: 4566da665d user: stephan tags: memleak-fixes)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/import.c.
224
225
226
227
228
229
230

231
232
233
234
235
236
237
      blob_appendf(&record, " %F", gg.zComment);
    }
    blob_appendf(&record, "\nU %F\n", gg.zUser);
    md5sum_blob(&record, &cksum);
    blob_appendf(&record, "Z %b\n", &cksum);
    fast_insert_content(&record, 0, 0, 1);
    blob_reset(&cksum);

  }
  import_reset(0);
}

/*
** Compare two ImportFile objects for sorting
*/







>







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
      blob_appendf(&record, " %F", gg.zComment);
    }
    blob_appendf(&record, "\nU %F\n", gg.zUser);
    md5sum_blob(&record, &cksum);
    blob_appendf(&record, "Z %b\n", &cksum);
    fast_insert_content(&record, 0, 0, 1);
    blob_reset(&cksum);
    blob_reset(&record);
  }
  import_reset(0);
}

/*
** Compare two ImportFile objects for sorting
*/
Changes to src/main.c.
358
359
360
361
362
363
364
365
366
367
368




















369
370
371
372
373
374
375
  */
  unloadTcl(g.interp, &g.tcl);
#endif
#ifdef FOSSIL_ENABLE_JSON
  cson_value_free(g.json.gc.v);
  memset(&g.json, 0, sizeof(g.json));
#endif
  free(g.zErrMsg);
  if(g.db){
    db_close(0);
  }




















  /*
  ** FIXME: The next two lines cannot always be enabled; however, they
  **        are very useful for tracking down TH1 memory leaks.
  */
  if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
    if( g.interp ){
      Th_DeleteInterp(g.interp); g.interp = 0;







<



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







358
359
360
361
362
363
364

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
  */
  unloadTcl(g.interp, &g.tcl);
#endif
#ifdef FOSSIL_ENABLE_JSON
  cson_value_free(g.json.gc.v);
  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);
  /* TODO: clean up the file-local content.c::contentCache
  ** via new function in that file */
  /*
  ** FIXME: The next two lines cannot always be enabled; however, they
  **        are very useful for tracking down TH1 memory leaks.
  */
  if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
    if( g.interp ){
      Th_DeleteInterp(g.interp); g.interp = 0;