Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#4173 closed defect (fixed)

Undefined behaviour in ptarray_segmentize2d

Reported by: Algunenano Owned by: pramsey
Priority: medium Milestone: PostGIS 2.5.0
Component: postgis Version: master
Keywords: Cc:

Description

It comes from test test_lwgeom_segmentize2d:

	linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
	lwgeom_request_interrupt();
	lineout = lwgeom_segmentize2d(linein, 1e-100);
	CU_ASSERT_EQUAL(lineout, NULL);
	lwgeom_free(linein);
$ ./cunit/.libs/lt-cu_tester test_lwgeom_segmentize2d

Running test 'test_lwgeom_segmentize2d' in suite 'measures'.
ptarray.c:450:10: runtime error: 1e+101 is outside the range of representable values of type 'unsigned int'

I'll need to check if it affects both 3.0 and 2.5.

I feel that the code is probably filled with these kind of issues (unsafe casting from double to integer types), but since those are corner cases I'll limit myself to fix whatever comes up when running unit tests.

WIP in https://github.com/postgis/postgis/pull/292

Change History (2)

comment:1 by Raul Marin, 6 years ago

Resolution: fixed
Status: newclosed

In 16723:

Fix undefined behaviour in ptarray_segmentize2d

Closes #4173
References #4153
Closes https://github.com/postgis/postgis/pull/292

comment:2 by pramsey, 6 years ago

In 16922:

Get a little hard-core on NaN representation, hopefully won't break obscure architectures (more than they are already broken)
References #4173

Note: See TracTickets for help on using tickets.