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

Commit2781489

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 parent745513c commit2781489

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
@@ -2848,7 +2848,7 @@ close_ps(PG_FUNCTION_ARGS)
28482848
}
28492849

28502850
/*
2851-
* at this point the "normal" from point will hit lseg. Thecloset point
2851+
* at this point the "normal" from point will hit lseg. Theclosest point
28522852
* will be somewhere on the lseg
28532853
*/
28542854
tmp=line_construct_pm(pt,invm);
@@ -2857,7 +2857,15 @@ close_ps(PG_FUNCTION_ARGS)
28572857
tmp->A,tmp->B,tmp->C);
28582858
#endif
28592859
result=interpt_sl(lseg,tmp);
2860-
Assert(result!=NULL);
2860+
2861+
/*
2862+
* ordinarily we should always find an intersection point, but that could
2863+
* fail in the presence of NaN coordinates, and perhaps even from simple
2864+
* roundoff issues. Return a SQL NULL if so.
2865+
*/
2866+
if (result==NULL)
2867+
PG_RETURN_NULL();
2868+
28612869
#ifdefGEODEBUG
28622870
printf("close_ps- result.x %f result.y %f\n",result->x,result->y);
28632871
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp