PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_from_twkb()

LWGEOM* lwgeom_from_twkb ( const uint8_t twkb,
size_t  twkb_size,
char  check 
)

WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory segment (this stops a malevolent user from declaring a one-ring polygon to have 10 rings, causing the WKB reader to walk off the end of the memory).

Parameters
checkparser check flags, see LW_PARSER_CHECK_* macros
sizeparser check flags, see LW_PARSER_CHECK_* macros

Check is a bitmask of: LW_PARSER_CHECK_MINPOINTS, LW_PARSER_CHECK_ODD, LW_PARSER_CHECK_CLOSURE, LW_PARSER_CHECK_NONE, LW_PARSER_CHECK_ALL

Definition at line 656 of file lwin_twkb.c.

657 {
658  int64_t coords[TWKB_IN_MAXCOORDS] = {0, 0, 0, 0};
660 
661  LWDEBUG(2,"Entering lwgeom_from_twkb");
662  LWDEBUGF(4,"twkb_size: %d",(int) twkb_size);
663 
664  /* Zero out the state */
665  memset(&s, 0, sizeof(twkb_parse_state));
666 
667  /* Initialize the state appropriately */
668  s.twkb = s.pos = twkb;
669  s.twkb_end = twkb + twkb_size;
670  s.check = check;
671  s.coords = coords;
672 
673  /* Read the rest of the geometry */
674  return lwgeom_from_twkb_state(&s);
675 }
char * s
Definition: cu_in_wkt.c:23
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define TWKB_IN_MAXCOORDS
Definition: lwin_twkb.c:31
LWGEOM * lwgeom_from_twkb_state(twkb_parse_state *s)
Internal function declarations.
Definition: lwin_twkb.c:562
Used for passing the parse state between the parsing functions.
Definition: lwin_twkb.c:37

References LWDEBUG, LWDEBUGF, lwgeom_from_twkb_state(), s, and TWKB_IN_MAXCOORDS.

Referenced by cu_twkb_idlist(), cu_twkb_in(), and LWGEOMFromTWKB().

Here is the call graph for this function:
Here is the caller graph for this function: