Fix signed integer overflow 61/211361/1
authorInHong Han <inhong1.han@samsung.com>
Fri, 2 Aug 2019 02:11:54 +0000 (11:11 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 2 Aug 2019 02:13:03 +0000 (11:13 +0900)
runtime error: signed integer overflow: 1560934086 * 1000000 cannot be represented in type 'long int'

Change-Id: I20e4ffbdde24f1d714982c1fd90260f629caa29c

ism/src/scim_helper.cpp

index f3c6008..0f63b24 100644 (file)
@@ -874,9 +874,9 @@ HelperAgent::wait_for_message(int cmd, int timeout)
 {
     struct timeval t0 = { 0, 0 };
     struct timeval t1 = { 0, 0 };
+    struct timeval t2 = { 0, 0 };
 
     gettimeofday(&t0, NULL);
-    int etime = 0;
 
     do {
         if (!m_impl->socket.is_connected() || !m_impl->recv.read_from_socket(m_impl->socket, timeout))
@@ -888,8 +888,8 @@ HelperAgent::wait_for_message(int cmd, int timeout)
         }
 
         gettimeofday(&t1, NULL);
-        etime = ((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
-    } while (etime < timeout);
+        timersub(&t1, &t0, &t2);
+    } while (t2.tv_sec < timeout);
 
     return false;
 }