gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] Issue with


From: Sergey Kashyrin
Subject: Re: [open-cobol-list] Issue with
Date: Mon Apr 10 09:03:02 2006

Robert,

It's been fixed.

replace

   if ((f->attr->digits % 2) == 0) {
       val1[size] &= 0x0f;
   }

by

if ((f->attr->digits % 2) == 0) {
 val1[20 - f->size] &= 0x0f;
}

The fix is already in a latest snapshot.

Regards,
Sergey


----- Original Message ----- From: "Robert Sherry" <address@hidden>
To: <address@hidden>
Sent: Monday, April 10, 2006 11:47 AM
Subject: [open-cobol-list] Issue with



Please consider the following code fragment from the file numeric.c:


int
cob_cmp_packed (cob_field *f, int n)
{
   int         sign;
   size_t          size;
   size_t          inc = 0;
   static int      lastval = 0;
   unsigned char       *p;
   unsigned char       val1[20];

   sign = COB_FIELD_HAVE_SIGN (f) ? cob_packed_get_sign (f) : 0;
   /* Field positive, value negative */
   if (sign >= 0 && n < 0) {
       return 1;
   }
   /* Field negative, value positive */
   if (sign < 0 && n >= 0) {
       return -1;
   }
   /* Both positive or both negative */
   p = f->data;
   for (size = 0; size < 20; size++) {
       if (size < 20 - f->size) {
           val1[size] = 0;
       } else {
           val1[size] = p[inc++];
       }
   }
   val1[19] &= 0xf0;
   if ((f->attr->digits % 2) == 0) {
       val1[size] &= 0x0f;
   }

Observe that upon exit from the for loop, the variable size will have a
value of 20. Therefore, the assignment statement:
val1[size] &= 0x0f;
has problems because it references val1[20] and val1 has only 20 elements.

Bob Sherry



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]