[comp.sources.bugs] Little Smalltalk bug

grady@postgres (Steven Grady) (10/05/87)

As distributed, executing "parse" (when creating imageFile) will core-
dump on a sun, because of a dereference through a NULL.  A simple fix
for this is to replace line 6 of memory.h:

# define streq(a,b) (strcmp(a,b) == 0)

with:

# define streq(a,b) ((a) == 0 ? 0 : (b) == 0 ? 0 : strcmp(a,b) == 0)

The reason being that in (for instance) newSymbol(), if the entry
in the hash table for which the current symbol hashes is uninitialized
(contains index 0), it uses the null object, which has a memory value
of NULL.  It then does a strcmp using that memory value.

This fix is a hack, but it is compatible with vaxen.  Probably a better
fix is to check the contents of the hash table entry, and only do the
streq() if it is non-0.  Unfortunately, there may be other places
where streq() is used without this check, and I don't have time to
look through the code for all of them..

	Steven
	grady@postgres.berkeley.edu
	...!ucbvax!grady