RE: compilter bug nighmare?
RE: compilter bug nighmare?
- Subject: RE: compilter bug nighmare?
- From: "MacArthur, Ian (SELEX) (UK)" <email@hidden>
- Date: Tue, 28 Jun 2005 09:51:19 +0100
- Thread-topic: Xcode-users Digest, Vol 2, Issue 311
> But hell, it works perfectly under win32 and early xcode.
> One more notice - works nice with Development target.
Hmm, how sure are you this code is correct? The fact that it works on some platforms and not others, and that it works in debug mode, smacks to me of buffer overflow issues...
I had a quick look at your code - I've interspersed a few comments on things that bothered me - I hope they might be helpful! But I'm probably just wrong...
> --------------------------------------- cut
> float coef [4 * FILTER_ORDER + 1];
> float history [2 * FILTER_ORDER];
>
>
> float getValue(float in)
> {
> unsigned int i;
> float *hist1_ptr, *hist2_ptr, *coef_ptr;
> float xout, new_hist, history1, history2;
>
> coef_ptr = coef; // coefficient pointer
>
> hist1_ptr = history; // first history
> hist2_ptr = hist1_ptr + 1; // next history
>
> // 1st number of coefficients array is
> overall input scale factor, * or filter gain
> xout = in * (*coef_ptr++);
>
> for (i = 0; i < length; i++)
// Where is length initialised?
// Are you certain it is always correctly initialised at the point that this code runs?
// What is its scope?
> {
> history1 = *hist1_ptr;
> history2 = *hist2_ptr;
>
> xout = xout - history1 * (*coef_ptr++);
> new_hist = xout - history2 *
> (*coef_ptr++); // poles
>
> xout = new_hist + history1 * (*coef_ptr++);
> xout = xout + history2 *
> (*coef_ptr++); // zeros
>
> *hist2_ptr++ = *hist1_ptr;
> *hist1_ptr++ = new_hist;
> hist1_ptr++;
> hist2_ptr++;
// Have you just double incremented the history pointers?
// They have been incremented once following the assignment, then again after it...
// Is that intended? It seems odd to me.
// Perhaps, because of this, you are walking off the end of the history buffer?
// Or I may be mising the point!
> }
> return xout;
> }
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden