source: fix potential problems
authorSooyoung Ha <yoosah.ha@samsung.com>
Mon, 21 Aug 2017 11:02:23 +0000 (20:02 +0900)
committer황석연/L4/프로/개발플랫폼팀/에스코어 <syeon-hwang@users.noreply.github.sec.samsung.net>
Tue, 22 Aug 2017 02:54:40 +0000 (11:54 +0900)
Signed-off-by: Sooyoung Ha <yoosah.ha@samsung.com>
SPC/Src/base/bignum.c
src/sockets.c
src/strutils.c

index 7dbf248e76e821ca8afc000c193fcc15ced4111a..94b8fe5f734f42ccce62c93e262cfd24e883a217 100755 (executable)
@@ -1596,7 +1596,7 @@ CRYPTOCORE_INTERNAL int SDRM_BN_Div(SDRM_BIG_NUM *BN_Quotient, SDRM_BIG_NUM *BN_
                return CRYPTO_SUCCESS;\r
        }\r
 \r
-       if (BN_Quotient == NULL)\r
+       if (BN_Quotient == NULL && BN_Remainder != NULL)\r
        {\r
                BN_Remainder->Length = temp_Divisor->Length;\r
 \r
index 722091d226e29f950d823cb6da6bfebee7c7a768..33cb4fa1da04a05458ad90324fcbd391b2d2028f 100755 (executable)
@@ -187,6 +187,10 @@ void local_socket_ready(SDB_SOCKET *s)
 
 void local_socket_close(SDB_SOCKET *s)
 {
+    if (s == NULL) {
+        D("ERROR! SDB_SOCKET s is null.\n");
+        return;
+    }
     D("LS(%X) FD(%d)\n", s->local_id, s->fd);
     if(HAS_SOCKET_STATUS(s, NOTIFY)) {
         D("LS(%X) fail to send notify\n", s->local_id);
index b48445936ea10a352a3d4adbc9e6531ca3f4ae88..d9f4234412250b504aa9688f853b9748ae46adfd 100755 (executable)
@@ -201,10 +201,15 @@ int strwrap(char * s, int w, char *** line_ret, int ** len_ret) {
     allocated = (tl / w) * 1.5 + 1;
 
     line = (char **) malloc(sizeof(char *) * allocated);
-    len = (int *) malloc(sizeof(int) * allocated);
+    if (line == NULL) {
+        return 0;
+    }
 
-    if (line == NULL || len == NULL)
+    len = (int *) malloc(sizeof(int) * allocated);
+    if (len == NULL) {
+        free(line);
         return 0;
+    }
 
     /*
      p will be an offset from the start of the string and the start of