maxl0rd / standingwave3

Flash ActionScript3 dynamic audio library
http://www.noteflight.com
160 stars 25 forks source link

Checking for NULL after calls to malloc, and throwing an Error #18

Closed jbaudanza closed 12 years ago

jbaudanza commented 12 years ago

Hey Max,

This is the change I e-mailed you about. LMK what you think.

I didn't touch reallocateSampleMemory in awave.com because I'm not sure I understand how it works.

float *buffer;

AS3_ArrayValue(args, "IntType, IntType, IntType", &oldframes, &newframes, &channels);

oldsize = oldframes * channels * sizeof(float);
newsize = newframes * channels * sizeof(float);

// realloc is slow :(
buffer = (float *) realloc(buffer, newsize); 

It looks like buffer is being passed into realloc without being initialized to any value

maxl0rd commented 12 years ago

Jon, looks good.

It turns out that you've found a bug in reallocateSampleMemory. I guess no one was using that. If you pass a null pointer to realloc then it just works the same as malloc. The only problem is that you've lost your original sample data :( ...