[mapserver-commits] r9976 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Mar 22 14:01:01 EDT 2010


Author: pramsey
Date: 2010-03-22 14:01:00 -0400 (Mon, 22 Mar 2010)
New Revision: 9976

Modified:
   trunk/mapserver/mapstring.c
Log:
Fix backwards handling of iconv errors (#2988)



Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c	2010-03-22 18:00:50 UTC (rev 9975)
+++ trunk/mapserver/mapstring.c	2010-03-22 18:01:00 UTC (rev 9976)
@@ -1618,7 +1618,7 @@
   iconv_t cd = NULL;
   const char *inp;
   char *outp, *out = NULL;
-  size_t len, bufsize, bufleft, status;
+  size_t len, bufsize, bufleft, iconv_status;
 
 #ifdef USE_FRIBIDI
   if(fribidi_parse_charset ((char*)encoding))
@@ -1648,11 +1648,11 @@
   outp = out;
 
   bufleft = bufsize;
-  status = -1;
+  iconv_status = -1;
 
   while (len > 0){
-    status = iconv(cd, (char**)&inp, &len, &outp, &bufleft);
-    if(status == -1){
+    iconv_status = iconv(cd, (char**)&inp, &len, &outp, &bufleft);
+    if(iconv_status == -1){
       msFree(out);
       iconv_close(cd);
       return strdup(string);
@@ -1682,7 +1682,7 @@
     size_t nStr;
     size_t nInSize;
     size_t nOutSize;
-    size_t nConv;
+    size_t iconv_status = -1;
     size_t nBufferSize;
 
     char* pszUTF8 = NULL;
@@ -1694,7 +1694,7 @@
         nBufferSize = ((nStr * 6) + 1);
         output = (char*) malloc (nBufferSize);
         if (output == NULL) {
-            msSetError(MS_MEMERR, NULL, "msGetEncodedString()");
+            msSetError(MS_MEMERR, NULL, "msConvertWideStringToUTF8()");
             return NULL;
         }
         if (nStr == 0) {
@@ -1711,8 +1711,8 @@
             nInSize = sizeof (wchar_t)*nStr;
             pszUTF8 = output;
             pwszWide = string;
-            nConv = iconv(cd, (char **)&pwszWide, &nInSize, &pszUTF8, &nOutSize);
-            if ((size_t)-1 != nConv &&  nOutSize != nBufferSize) {
+            iconv_status = iconv(cd, (char **)&pwszWide, &nInSize, &pszUTF8, &nOutSize);
+            if ((size_t)-1 == iconv_status) {
                 switch (errno) {
                     case E2BIG:
                     errormessage = "There is not sufficient room in buffer";



More information about the mapserver-commits mailing list