Resolve a prevent issue.
authorJungki Kwak <jungki.kwak@samsung.com>
Mon, 8 Apr 2013 02:10:38 +0000 (11:10 +0900)
committerGerrit Code Review <gerrit2@kim11>
Mon, 8 Apr 2013 07:56:08 +0000 (16:56 +0900)
Changes)
It is added to check null check after allocation memory.
modified:   provider/download-provider-db.c

Change-Id: I9b18ad1244ffaccacfd0af66b2e7c7645d3859fd

provider/download-provider-db.c

index 04a26ae..7dc26c9 100755 (executable)
@@ -1331,6 +1331,7 @@ static char *__merge_strings(char *dest, const char *src, char sep)
 {
        int dest_length = 0;
        int src_length = 0;
+       char *temp_dest = NULL;
 
        if (dest == NULL || src == NULL)
                return NULL;
@@ -1338,10 +1339,14 @@ static char *__merge_strings(char *dest, const char *src, char sep)
        dest_length = strlen(dest);
        src_length = strlen(src);
 
-       dest = sqlite3_realloc(dest, dest_length + src_length + 1);
-       dest = strncat(dest, &sep, 1);
-       dest = strncat(dest, src, src_length);
-       return dest;
+       temp_dest = sqlite3_realloc(dest, dest_length + src_length + 1);
+       if (temp_dest == NULL) {
+               free(dest);
+               return NULL;
+       }
+       temp_dest = strncat(temp_dest, &sep, 1);
+       temp_dest = strncat(temp_dest, src, src_length);
+       return temp_dest;
 }
 
 static char *__get_conds_query(int count, db_conds_list_fmt *conds, char *op)