From: Sooyoung Ha Date: Mon, 21 Aug 2017 11:02:23 +0000 (+0900) Subject: source: fix potential problems X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c38d2015a30a2b4ecc409507dcd8ca9b3b780d54;p=sdk%2Ftools%2Fsdb.git source: fix potential problems Signed-off-by: Sooyoung Ha --- diff --git a/SPC/Src/base/bignum.c b/SPC/Src/base/bignum.c index 7dbf248..94b8fe5 100755 --- a/SPC/Src/base/bignum.c +++ b/SPC/Src/base/bignum.c @@ -1596,7 +1596,7 @@ CRYPTOCORE_INTERNAL int SDRM_BN_Div(SDRM_BIG_NUM *BN_Quotient, SDRM_BIG_NUM *BN_ return CRYPTO_SUCCESS; } - if (BN_Quotient == NULL) + if (BN_Quotient == NULL && BN_Remainder != NULL) { BN_Remainder->Length = temp_Divisor->Length; diff --git a/src/sockets.c b/src/sockets.c index 722091d..33cb4fa 100755 --- a/src/sockets.c +++ b/src/sockets.c @@ -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); diff --git a/src/strutils.c b/src/strutils.c index b484459..d9f4234 100755 --- a/src/strutils.c +++ b/src/strutils.c @@ -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