[postgis-users] Bug in postgis/lwgeom_geos_prepared.c

Stephen Woodbridge woodbri at swoodbridge.com
Mon Apr 22 10:04:59 PDT 2013


Hi Guys,

In reading through the code in "postgis/lwgeom_geos_prepared.c" I have 
noticed a bug that you probably should fix:

static void
DeletePrepGeomHashEntry(MemoryContext mcxt)
{
     void **key;
     PrepGeomHashEntry *he;

     /* The hash key is the MemoryContext pointer */
     key = (void *)&mcxt;

     /* Delete the projection object from the hash */
     he = (PrepGeomHashEntry *) hash_search(PrepGeomHash, key, 
HASH_REMOVE, NULL);

     he->prepared_geom = NULL;
     he->geom = NULL;

     if (!he)
         elog(ERROR, "DeletePrepGeomHashEntry: There was an error 
removing the geometry object from this MemoryContext (%p)", (void *)mcxt);
}


Notice that  if he == NULL, you will never get to the if (!he) statement 
because you will have already segv'd on the prior two statements trying 
to access he.

-Steve



More information about the postgis-users mailing list