]> 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 b107ee9515c1265e589ebfcd6924c8fc3ac77143..3eaffb9f07120c5089c0aa2bef585cfc4594d5f2 100644 (file)
@@ -332,13 +332,6 @@ return stg_timegm(&brokenTime);
 void ParseAnyString(const char * c, string * msg, const char * enc)
 {
 iconv_t cd;
 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, "");
 
 
 setlocale(LC_ALL, "");
 
@@ -349,11 +342,6 @@ const char * charsetT = enc;
 
 size_t nconv = 1;
 
 
 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)
     {
 cd = iconv_open(charsetT, charsetF);
 if (cd == (iconv_t) -1)
     {
@@ -369,6 +357,17 @@ if (cd == (iconv_t) -1)
     exit(ICONV_ERR_CODE);
     }
 
     exit(ICONV_ERR_CODE);
     }
 
+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
 #if defined(CONST_ICONV)
 nconv = iconv (cd, (const char**)&inbuf, &insize, &outbuf, &outsize);
 #else