Csound Csound-dev Csound-tekno Search About

RE: [Cs-dev] Gabriel's opcodes

Date2005-02-10 14:31
From"gogins@pipeline.com"
SubjectRE: [Cs-dev] Gabriel's opcodes
*fno is assigned from (int) *p->kfn. Of course this code assumes that the
assignment takes place before the next clause in the || expression. I'm not
sure whether the C language standard validates this assumption.

Original Message:
-----------------
From:  jpff@codemist.co.uk
Date: Thu, 10 Feb 2005 10:14:49 +0000
To: csound-devel@lists.sourceforge.net
Subject: [Cs-dev] Gabriel's opcodes


I have been reviewing the code, and the functions tabplay_k and
tabrec_k contain a serious error I do not understand

        MYFLT *fno;             /* **** THIS IS AN ERROR **** Uninitialised
*/
        if ((*fno = (int)*p->kfn) <= 0 || *fno > csound->maxfnum || (ftp =
ftnp2find(csound,fno)) == NULL) {
          /*sprintf(errmsg, Str(X_315,"Invalid ftable no. %f"),*p->kfn); */
          sprintf(errmsg, "Invalid ftable no. %f",*p->kfn);
          return perferror(errmsg);
        }

*fno is not a valid location and this may crash in an arbitrary way.
Does anyone understand what it is supposed to do?

==John ffitch


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-02-10 15:08
Fromjpff@codemist.co.uk
SubjectRe: [Cs-dev] Gabriel's opcodes
>>>>> "gogins@pipeline" == gogins@pipeline com  writes:

 gogins@pipeline> *fno is assigned from (int) *p->kfn. Of course this code assumes that the
 gogins@pipeline> assignment takes place before the next clause in the || expression. I'm not
 gogins@pipeline> sure whether the C language standard validates this assumption.

Not so.  It writes a value into the address to which fno points, but
it not initialised so the value (int)*p->kfn is written to somewhere,
but not necessarily a valid place.  Programming 101 which I teach next
week!

==John ffitch


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-02-10 15:27
FromIstvan Varga
SubjectRe: [Cs-dev] Gabriel's opcodes
jpff@codemist.co.uk wrote:
>>>>>>"gogins@pipeline" == gogins@pipeline com  writes:
> 
> 
>  gogins@pipeline> *fno is assigned from (int) *p->kfn. Of course this code assumes that the
>  gogins@pipeline> assignment takes place before the next clause in the || expression. I'm not
>  gogins@pipeline> sure whether the C language standard validates this assumption.
> 
> Not so.  It writes a value into the address to which fno points, but
> it not initialised so the value (int)*p->kfn is written to somewhere,
> but not necessarily a valid place.  Programming 101 which I teach next
> week!

How about replacing the line
   MYFLT *fno;
with
   MYFLT fno_;
   MYFLT *fno;
   fno = &fno_;



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net