Fix defects about static_overflow detected by static analysis tool 98/57698/1
authorsungwook79.park <sungwook79.park@samsung.com>
Thu, 21 Jan 2016 12:49:01 +0000 (21:49 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 22 Jan 2016 00:51:33 +0000 (09:51 +0900)
Change-Id: I869256731639944cc707086b28ebce601f9afb34
Signed-off-by: sungwook79.park <sungwook79.park@samsung.com>
ism/modules/config/scim_simple_config.cpp
ism/src/scim_global_config.cpp

index 8cb2050..0a6c563 100644 (file)
@@ -534,32 +534,29 @@ SimpleConfig::parse_config (std::istream &is, KeyValueRepository &config)
 {
     char *conf_line = new char [SCIM_MAX_CONFIG_LINE_LENGTH];
 
-    while (!is.eof()) {
-        is.getline(conf_line, SCIM_MAX_CONFIG_LINE_LENGTH);
-        if (!is.eof()) {
-            String normalized_line = trim_blank(conf_line);
-
-            if ((normalized_line.find_first_of("#") > 0) && (normalized_line.length() != 0)) {
-                if (normalized_line.find_first_of("=") == String::npos) {
-                    SCIM_DEBUG_CONFIG(2) << " Invalid config line : " << normalized_line << "\n";
-                    continue;
-                }
-
-                if (normalized_line[0] == '=') {
-                    SCIM_DEBUG_CONFIG(2) << " Invalid config line : " << normalized_line << "\n";
-                    continue;
-                }
-
-                String param = get_param_portion(normalized_line);
-                KeyValueRepository::iterator i = config.find(param);
-
-                if (i != config.end()) {
-                    SCIM_DEBUG_CONFIG(2) << " Config entry " << normalized_line << " has been read.\n";
-                } else {
-                    String value = get_value_portion (normalized_line);
-                    config [param] = value;
-                    SCIM_DEBUG_CONFIG(2) << " Config entry " << param << "=" << value << " is successfully read.\n";
-                }
+    while (is.getline(conf_line, SCIM_MAX_CONFIG_LINE_LENGTH)) {
+        String normalized_line = trim_blank(conf_line);
+
+        if ((normalized_line.find_first_of("#") > 0) && (normalized_line.length() != 0)) {
+            if (normalized_line.find_first_of("=") == String::npos) {
+                SCIM_DEBUG_CONFIG(2) << " Invalid config line : " << normalized_line << "\n";
+                continue;
+            }
+
+            if (normalized_line[0] == '=') {
+                SCIM_DEBUG_CONFIG(2) << " Invalid config line : " << normalized_line << "\n";
+                continue;
+            }
+
+            String param = get_param_portion(normalized_line);
+            KeyValueRepository::iterator i = config.find(param);
+
+            if (i != config.end()) {
+                SCIM_DEBUG_CONFIG(2) << " Config entry " << normalized_line << " has been read.\n";
+            } else {
+                String value = get_value_portion (normalized_line);
+                config [param] = value;
+                SCIM_DEBUG_CONFIG(2) << " Config entry " << param << "=" << value << " is successfully read.\n";
             }
         }
     }
index 414c68a..55580ab 100644 (file)
@@ -105,8 +105,7 @@ __parse_config (std::ifstream &is, KeyValueRepository &repository)
 {
     char *conf_line = new char [10000];
 
-    while (!is.eof ()) {
-        is.getline (conf_line, 10000);
+    while (is.getline (conf_line, 10000)) {
         String normalized_line = __trim_blank(conf_line);
         if ((normalized_line.find_first_of("#") > 0) && (normalized_line.length() != 0)) {
             if (normalized_line.find_first_of("=") == String::npos) {