]> git.stg.codes - stg.git/blobdiff - projects/sgconf/main.cpp
Various fixes of issues reported by static analyzers.
[stg.git] / projects / sgconf / main.cpp
index e0ab43ced7c2caba4c80fa83c730cd9aea6e5d84..3eaffb9f07120c5089c0aa2bef585cfc4594d5f2 100644 (file)
@@ -332,13 +332,6 @@ return stg_timegm(&brokenTime);
 void ParseAnyString(const char * c, string * msg, const char * enc)
 {
 iconv_t cd;
-char * ob = new char[strlen(c) + 1];
-char * ib = new char[strlen(c) + 1];
-
-strcpy(ib, c);
-
-char * outbuf = ob;
-char * inbuf = ib;
 
 setlocale(LC_ALL, "");
 
@@ -349,11 +342,6 @@ const char * charsetT = enc;
 
 size_t nconv = 1;
 
-size_t insize = strlen(ib);
-size_t outsize = strlen(ib);
-
-insize = strlen(c);
-
 cd = iconv_open(charsetT, charsetF);
 if (cd == (iconv_t) -1)
     {
@@ -369,7 +357,18 @@ if (cd == (iconv_t) -1)
     exit(ICONV_ERR_CODE);
     }
 
-#if defined(FREE_BSD) || defined(FREE_BSD5)
+char * ob = new char[strlen(c) + 1];
+char * ib = new char[strlen(c) + 1];
+
+strcpy(ib, c);
+
+char * outbuf = ob;
+char * inbuf = ib;
+
+size_t insize = strlen(c);
+size_t outsize = strlen(ib);
+
+#if defined(CONST_ICONV)
 nconv = iconv (cd, (const char**)&inbuf, &insize, &outbuf, &outsize);
 #else
 nconv = iconv (cd, &inbuf, &insize, &outbuf, &outsize);