On Sat, 28 Dec 2013, Joe Mistachkin wrote:

> Sergei Gavrikov wrote:
> >
> > I found that TH1 does not catch "Divide by 0" under certain conditions
> > (if numerator or denominator (or both) are floating-point numbers) and
> > quite hangs Fossil:
> >
>
> Thanks for the report.  Fixed here:
>
>       https://www.fossil-scm.org/index.html/info/479b3de1d2

Sorry for delayed answer. Thank you for this fix. One thing that I found
today, there are a few early returns in exprEval() which can cause memory
leaks (nLeft, nRight stay allocated after return). I would say 'goto' is
the simplest workaround to fix those lines, but, please, take a look.

$.02: It seems to me it is worth to add to test_th_eval() an assert for
nOutstagingMalloc==0, then it will be more easier to catch the leaks in
a future

  % ./fossil test-th-eval "expr 42%0"
  TH_ERROR: Modulo by 0: 42
  fossil: ../src/th_main.c:1255: test_th_eval: Assertion 
`nOutstandingMalloc==0' failed.
  Aborted

Without this check all tests from test/th1.test does pass without any
noise.

Sergei

Index: src/th_main.c
==================================================================
--- src/th_main.c
+++ src/th_main.c
@@ -1249,6 +1249,8 @@
   Th_FossilInit(TH_INIT_DEFAULT);
   rc = Th_Eval(g.interp, 0, g.argv[2], -1);
   zRc = Th_ReturnCodeName(rc, 1);
   fossil_print("%s%s%s\n", zRc, zRc ? ": " : "", Th_GetResult(g.interp, 0));
   Th_PrintTraceLog();
+  Th_DeleteInterp(g.interp);
+  assert( nOutstandingMalloc==0 );
 }

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to