bug-gnustep
[Top][All Lists]
Advanced

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

fix for minor bug in NSMapTable (snapshot 20020503)


From: Lars Sonchocky-Helldorf
Subject: fix for minor bug in NSMapTable (snapshot 20020503)
Date: Mon, 6 May 2002 02:46:16 +0200

In NSMapTable.m the lines 338 to 357 should read:

void *
NSMapGet(NSMapTable *table, const void *key)
{
  GSIMapNode    n;

  if (table == 0)
    {
      NSWarnFLog(@"Nul table argument supplied");
      return 0;
    }
  n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
  if (n == 0)
    {
      return 0;
    }
  else
    {
      return n->value.ptr;
    }
}

instead of:

void *
NSMapGet(NSMapTable *table, const void *key)
{
  GSIMapNode    n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);

  if (table == 0)
    {
      NSWarnFLog(@"Nul table argument supplied");
      return 0;
    }
  n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
  if (n == 0)
    {
      return 0;
    }
  else
    {
      return n->value.ptr;
    }
}

otherwise GSIMapNodeForKey might be invoked with an empty table argument which results in a BUS ERROR because GSIMapNodeForKey is not protected against an empty table argument. I guess the code:

  if (table == 0)
    {
      NSWarnFLog(@"Nul table argument supplied");
      return 0;
    }

is meant to do that BEFORE GSIMapNodeForKey is invoked and the code in line 341 was just overseen.

greetings, Lars




reply via email to

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