Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST_LocateBetweenElevations: fix segfault on interrupt #642

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

kalenikaliaksandr
Copy link
Contributor

pointarray returned by ptarray_clamp_to_ordinate_range need to be null checked before dereferencing since when request is interrupted, null is returned here

LW_ON_INTERRUPT(ptarray_free(opa); return NULL);
and segmentation fault happens.

@@ -736,6 +736,7 @@ lwpoly_clip_to_ordinate_range(const LWPOLY *poly, char ordinate, double from, do
/* Ret number of points */
POINTARRAY *pa = ptarray_clamp_to_ordinate_range(poly->rings[i], ordinate, from, to, LW_TRUE);

assert(pa);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert will crash it on the spot here instead of the other spot. does not look like a lot of change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to be more like if (!pa) return NULL; in whole call chain and lwerror on the very upper level.

or, why don't we lwerror right in LW_ON_INTERRUPT? it's not like the calculation is going to get finished anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree about assert -- replaced with if (!pa) return NULL;
lwgeom_clip_to_ordinate_range will handle NULL here.

if (!out_col)
lwerror("lwgeom_clip_to_ordinate_range clipping routine returned NULL");

@kalenikaliaksandr kalenikaliaksandr force-pushed the st_locatebetween-fix-crash branch 2 times, most recently from a9e7151 to 11296b5 Compare September 22, 2021 09:28
@strk strk merged commit 4bcabb6 into postgis:master Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants