[PD-dev] Pointers changing/corrupting (used to be "signal nan values")

IOhannes m zmoelnig zmoelnig at iem.at
Wed Apr 27 13:51:40 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2011-04-27 13:17, Andrew Hassall wrote:
> No thats fine, I've attached both c files. (they are a bit messy at
> the moment due to debugging and tearing them apart sorry, if you need
> cleaner commented code I can comment it up no problem)

a quick glance at lpcanalysis_tilde_new() reveils, that you are
allocating data on the stack (which will be freed as soon as you leave
lpcanalysis_tilde_new()!), store their addresses and re-use them later
(when the memory is already freed).

you cannot do:
<ko>
void*lpca_new() {
 //...
 t_sample winlis[2088];
 x->win=winlis;
 //...
}
</ko>

instead you have to do:
<ok>
void lpca_free(x) {
 freebytes(x->win);
 //...
}
void*lpca_new() {
 //...
 x->win=getbytes(2088*sizeof(t_sample));
 //...
}
</ok>

mfgasdr
IOhannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk24A0wACgkQkX2Xpv6ydvQ5EACaAtBHvzr0T7QpzvcfsaFTR4X9
ugAAoIdCSDfLOc1qMiegTv0+gRncrJq0
=Tt6y
-----END PGP SIGNATURE-----

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3636 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20110427/d42dd687/attachment.bin>


More information about the Pd-dev mailing list