Skip to content

Commit

Permalink
lwpoly_construct_circle: Avoid division by zero (Raúl Marín Rodríguez)
Browse files Browse the repository at this point in the history
Closes #4003
Closes postgis#199


git-svn-id: http://svn.osgeo.org/postgis/trunk@16364 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information
pramsey committed Jan 26, 2018
1 parent f16a308 commit 5430d55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions liblwgeom/lwpoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ LWPOLY*
lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t segments_per_quarter, char exterior)
{
const uint32_t segments = 4*segments_per_quarter;
const double theta = 2*M_PI / segments;
double theta;
LWPOLY *lwpoly;
POINTARRAY *pa;
POINT4D pt;
uint32_t i;

if (segments_per_quarter < 1)
if (segments_per_quarter == 0)
{
lwerror("Need at least one segment per quarter-circle.");
return NULL;
Expand All @@ -138,6 +138,8 @@ lwpoly_construct_circle(int srid, double x, double y, double radius, uint32_t se
return NULL;
}

theta = 2*M_PI / segments;

lwpoly = lwpoly_construct_empty(srid, LW_FALSE, LW_FALSE);
pa = ptarray_construct_empty(LW_FALSE, LW_FALSE, segments + 1);

Expand Down

0 comments on commit 5430d55

Please sign in to comment.