[geos-devel] When do topology functions return NULL?

Sandro Santilli strk at kbt.io
Wed Jul 18 08:18:16 PDT 2018

On Wed, Jul 18, 2018 at 09:51:07AM -0400, Andrew Hershberger wrote:
> GEOSwift is a Swift wrapper for geos's thread-safe C interface. A recent
> commit (
> https://github.com/GEOSwift/GEOSwift/commit/6006a7493dc040909903559d6b49cfe5d0070ecc)
> added NULL checks for the return values of the topology operations, but
> from inspection of the geos code, it seems like the topology operations
> only return NULL if the handle is NULL or uninitialized, which our wrapper
> prevents. We're using version 3.5.0. Do these topology operations return
> NULL in any other cases?

My inspection shows NULL is returned on exception. Example code:

Geometry *
GEOSUnion_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2)
     return return g1->Union(g2);
  catch (...)
    // no return here
  return NULL; // <--- on exception we get here


More information about the geos-devel mailing list