[PD-dev] [PATCH] Avoid crash in vd~ for nan/inf input values

Kjetil Matheussen k.s.matheussen at gmail.com
Tue Sep 10 16:17:59 CEST 2013


As previous discussed in the thread "Whose fault is this crash? (nan and
inf)",
a patch is pasted below to fix the problem.

It might be possible to fix the problem a better way, by checking whether
the integer index variable (called "idelsamps") is within bounds, but the
complexity
of the code goes a little bit above my head.

The other two situations mentioned in the thread that might have
this problem, namely tabread4~ and poke~, should not have
this problem since there are checks that the integer index values
are within bounds.


diff --git a/pure-data/src/d_array.c b/pure-data/src/d_array.c
index d365cf2..9c16a85 100644
--- a/pure-data/src/d_array.c
+++ b/pure-data/src/d_array.c
@@ -423,7 +423,11 @@ static t_int *tabread4_tilde_perform(t_int *w)

     for (i = 0; i < n; i++)
     {
-        double findex = *in++ + onset;
+        t_sample inval = *in++;
+        if(!isfinite(inval))
+          inval = 0.0f;
+
+        double findex = inval + onset;
         int index = findex;
         t_sample frac,  a,  b,  c,  d, cminusb;
         static int count;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20130910/af6ec806/attachment.htm>


More information about the Pd-dev mailing list