Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16e28fc

Browse files
committed
Fix crash in close_ps() for NaN input coordinates.
The Assert() here seems unreasonably optimistic. Andreas Seltenreichfound that it could fail with NaNs in the input geometries, and itseems likely to me that it might fail in corner cases due to roundofferror, even for ordinary input values. As a band-aid, make the functionreturn SQL NULL instead of crashing.Report: <87d1md1xji.fsf@credativ.de>
1 parent2e51ae1 commit16e28fc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎src/backend/utils/adt/geo_ops.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,7 +2913,7 @@ close_ps(PG_FUNCTION_ARGS)
29132913
}
29142914

29152915
/*
2916-
* at this point the "normal" from point will hit lseg. Thecloset point
2916+
* at this point the "normal" from point will hit lseg. Theclosest point
29172917
* will be somewhere on the lseg
29182918
*/
29192919
tmp=line_construct_pm(pt,invm);
@@ -2922,7 +2922,15 @@ close_ps(PG_FUNCTION_ARGS)
29222922
tmp->A,tmp->B,tmp->C,tmp->m);
29232923
#endif
29242924
result=interpt_sl(lseg,tmp);
2925-
Assert(result!=NULL);
2925+
2926+
/*
2927+
* ordinarily we should always find an intersection point, but that could
2928+
* fail in the presence of NaN coordinates, and perhaps even from simple
2929+
* roundoff issues. Return a SQL NULL if so.
2930+
*/
2931+
if (result==NULL)
2932+
PG_RETURN_NULL();
2933+
29262934
#ifdefGEODEBUG
29272935
printf("close_ps- result.x %f result.y %f\n",result->x,result->y);
29282936
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp