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

Commit884bae1

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 parent1f9534b commit884bae1

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
@@ -2914,7 +2914,7 @@ close_ps(PG_FUNCTION_ARGS)
29142914
}
29152915

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp