Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!swrinde!cs.utexas.edu!uunet!image.soe.clarkson.edu!news From: gary@sun.mcs.clarkson.edu (Gary Levin) Newsgroups: comp.sys.mac.programmer Subject: New scanf bug Message-ID: Date: 31 Oct 89 18:20:32 GMT Sender: news@sun.soe.clarkson.edu Distribution: comp Organization: Clarkson University, Potsdam NY Lines: 42 A new scanf bug has appeared. If you read a string using %*s, the unassigned string is stored in a random memory location (pointer 0). This accounted for my earlier problem of an alert message being changed. Apparently, using separate strings put the text in memory location 0. Under the debugger, something else must be there. Correction to ``scanf.c'' in ANSI shown below; just add the line above the ***. Please report any other errors found. It would be appreciated if the Symantec folks would periodically post bug reports from other sources to this list. string: if (!F.haveWidth) F.fieldWidth = INT_MAX; if (!F.suppress) s = va_arg(arg, char *); for (; c != EOF; c = getc(fp), ++nread) { --F.fieldWidth; if (!testbit(c)) break; F.valid = TRUE; if (!F.suppress) *s++ = c; **************** only assign if not suppressed. if (F.fieldWidth == 0) goto endstring; } ungetc(c, fp), --nread; endstring: if (!F.valid) goto done; if (!F.suppress) { *s = 0; ++nassigned; } ++nconverted; continue; -- Gary Levin/Dept of Math & CS/Clarkson Univ/Potsdam, NY 13676/(315) 268-2384 BitNet: gary@clutx Internet: gary@clutx.clarkson.edu