Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Sep 2020 03:19:20 +0000 (UTC)
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r548447 - in head/databases/pgsphere: . files
Message-ID:  <202009130319.08D3JKkK075102@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kbowling
Date: Sun Sep 13 03:19:20 2020
New Revision: 548447
URL: https://svnweb.freebsd.org/changeset/ports/548447

Log:
  databases/pgsphere: stop using VLAs to fix PG12 compilation
  
  PR:		248657
  Reported by:	vvd@unislabs.com
  Obtained from:	https://github.com/akorotkov/pgsphere/pull/14
  Sponsored by:	BBOX.io

Added:
  head/databases/pgsphere/files/
  head/databases/pgsphere/files/patch-path.c   (contents, props changed)
  head/databases/pgsphere/files/patch-polygon.c   (contents, props changed)
Modified:
  head/databases/pgsphere/Makefile

Modified: head/databases/pgsphere/Makefile
==============================================================================
--- head/databases/pgsphere/Makefile	Sun Sep 13 03:11:20 2020	(r548446)
+++ head/databases/pgsphere/Makefile	Sun Sep 13 03:19:20 2020	(r548447)
@@ -3,7 +3,7 @@
 
 PORTNAME=	pgsphere
 PORTVERSION=	1.1.5
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	databases geography
 
 MAINTAINER=	sunpoet@FreeBSD.org

Added: head/databases/pgsphere/files/patch-path.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pgsphere/files/patch-path.c	Sun Sep 13 03:19:20 2020	(r548447)
@@ -0,0 +1,25 @@
+--- path.c.orig	2019-10-30 10:18:38 UTC
++++ path.c
+@@ -513,13 +513,21 @@ spherepath_in(PG_FUNCTION_ARGS)
+ 	nelem = get_path_count();
+ 	if (nelem > 1)
+ 	{
+-		SPoint		arr[nelem];
++		SPoint*		arr = (SPoint*)malloc(nelem*sizeof(SPoint));
++		if (arr == NULL) {
++			reset_buffer();
++			elog(ERROR, "spherepath_in: could not allocate array");
++			PG_RETURN_NULL();
++		}
+ 
+ 		for (i = 0; i < nelem; i++)
+ 		{
+ 			get_path_elem(i, &arr[i].lng, &arr[i].lat);
+ 		}
+ 		path = spherepath_from_array(&arr[0], nelem);
++
++		//free array
++		free(arr);
+ 	}
+ 	else
+ 	{

Added: head/databases/pgsphere/files/patch-polygon.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pgsphere/files/patch-polygon.c	Sun Sep 13 03:19:20 2020	(r548447)
@@ -0,0 +1,54 @@
+--- polygon.c.orig	2019-10-30 10:18:38 UTC
++++ polygon.c
+@@ -824,13 +824,21 @@ spherepoly_in(PG_FUNCTION_ARGS)
+ 	nelem = get_path_count();
+ 	if (nelem > 2)
+ 	{
+-		SPoint		arr[nelem];
++		// allocate arr
++		SPoint* arr = (SPoint *)malloc(nelem * sizeof(SPoint));
++		if (arr == NULL) {
++			reset_buffer();
++			elog(ERROR, "spherepoly_in: Could not allocate array.");
++			PG_RETURN_NULL();
++		}
+ 
+ 		for (i = 0; i < nelem; i++)
+ 		{
+ 			get_path_elem(i, &arr[i].lng, &arr[i].lat);
+ 		}
+ 		poly = spherepoly_from_array(&arr[0], nelem);
++		// free allocated array
++		free(arr);
+ 	}
+ 	else
+ 	{
+@@ -892,11 +900,17 @@ spherepoly_area(PG_FUNCTION_ARGS)
+ {
+ 	SPOLY	   *poly = PG_GETARG_SPOLY(0);
+ 	int32		i;
+-	SPoint		s[poly->npts + 2];
++	SPoint     *s = (SPoint*)malloc((poly->npts+2)*sizeof(SPoint));
++	//SPoint		s[poly->npts + 2];
+ 	SPoint		stmp[2];
+ 	SEuler		se;
+ 	float8		sum = 0.0;
+ 
++	if (s == NULL) {
++		elog(ERROR, "spherepoly_area: Could not allocate array.");
++		PG_RETURN_NULL();
++	}
++
+ 	memcpy((void *) &s[1],
+ 		   (void *) &poly->p[0],
+ 		   poly->npts * sizeof(SPoint));
+@@ -935,6 +949,9 @@ spherepoly_area(PG_FUNCTION_ARGS)
+ 	{
+ 		sum = 0.0;
+ 	}
++
++	// free array
++	free(s);
+ 
+ 	PG_RETURN_FLOAT8(sum);
+ }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009130319.08D3JKkK075102>