[comp.graphics] Found two bugs in QRT

kory@avatar.UUCP (Kory Hamzeh) (03/02/89)

I have found two bugs in QRT 1.4 and have included the fixes in this
posting.

The first bug is in function GetToken in file lexer.c. The line
was coded as follows:

    s[x++] = c = toupper(towhite(fgetc(stdin)));

This will not work on all machine because toupper() will screw up on some
machines if the argument is already upper case. I changed the line to read
as follows:

    c = towhite(fgetc(stdin));
    s[x++] = c = (islower(c) ? toupper(c) : c);

The next bug is located in function Get_Next_Name() in lexer.c. The lines
was coded as follows:

  if ((s=malloc(strlen(str)))==NULL)
    Error(MALLOC_FAILURE,1503);
  strcpy(s, str);

It should be changed to something more like this:

  if ((s=malloc(strlen(str) + 1))==NULL)
    Error(MALLOC_FAILURE,1503);
  strcpy(s, str);

Don't forget a byte for the NULL charactor!! It caused the next call to
malloc() to loop indefinitely on my machine.

Well folks, if I find anymore problems I will post.

--kory


-- 
-------------------------------------------------------------------------------
Kory Hamzeh			    UUCP:     ..!uunet!psivax!quad1!avatar!kory
				    INTERNET: avatar!kory@quad.com