]> granicus.if.org Git - postgis/commitdiff
Work around difference between behavior of MS snprintf and C99 snprintf. (#1668)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 9 Mar 2012 17:46:29 +0000 (17:46 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 9 Mar 2012 17:46:29 +0000 (17:46 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9435 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/stringbuffer.c

index ba68df5fadff77c877ffcb8cfcc5fded948b6c42..88828500b7d23f00ee62ca81bb69aefb8a1ed133 100644 (file)
@@ -207,11 +207,10 @@ stringbuffer_avprintf(stringbuffer_t *s, const char *fmt, va_list ap)
        /* Print to our buffer */
        len = vsnprintf(s->str_end, maxlen, fmt, ap);
 
-       /* Propogate any printing errors upwards (check errno for info) */
-       if ( len < 0 ) return len;
-
-       /* We didn't have enough space! Expand the buffer. */
-       if ( len >= maxlen )
+       /* We didn't have enough space! */
+       /* Either Unix vsnprint returned write length larger than our buffer */
+       /*     or Windows vsnprintf returned an error code. */
+       if ( (len >= maxlen) || (len < 0) )
        {
                stringbuffer_makeroom(s, len + 1);
                maxlen = (s->capacity - (s->str_end - s->str_start));