[DF170725-00908] Fix the Svace issue 20/141920/3 accepted/tizen/4.0/unified/20170816.010921 accepted/tizen/unified/20170804.025626 submit/tizen/20170803.070200 submit/tizen_4.0/20170811.094300
authorjh8801.jung <jh8801.jung@samsung.com>
Wed, 2 Aug 2017 04:07:11 +0000 (13:07 +0900)
committerjh8801.jung <jh8801.jung@samsung.com>
Thu, 3 Aug 2017 04:49:50 +0000 (13:49 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
Change-Id: Ifc713bbeacd5246d4c39a527956f9f1bc0e103c4

packaging/libmtp.spec
src/playlist-spl.c

index 69ca86e..3db74f0 100755 (executable)
@@ -3,7 +3,7 @@
 Name:       libmtp
 Summary:    Library for media transfer protocol (mtp)
 Version:    1.1.11
-Release:    9
+Release:    10
 Group:      Network & Connectivity/Other
 License:    LGPL-2.1
 Source0:    libmtp-%{version}.tar.gz
index e1c6ad9..7847b5d 100755 (executable)
@@ -121,6 +121,11 @@ void spl_to_playlist_t(LIBMTP_mtpdevice_t* device, PTPObjectInfo *oi,
   // Fill in playlist metadata
   // Use the Filename as the playlist name, dropping the ".spl" extension
   pl->name = malloc(sizeof(char)*(strlen(oi->Filename) -4 +1));
+  if (pl->name == NULL) {
+    LIBMTP_ERROR("pl->name malloc failed");
+    return;
+  }
+
   memcpy(pl->name, oi->Filename, strlen(oi->Filename) -4);
   // Set terminating character
   pl->name[strlen(oi->Filename) - 4] = 0;
@@ -147,6 +152,7 @@ void spl_to_playlist_t(LIBMTP_mtpdevice_t* device, PTPObjectInfo *oi,
     // FIXME     add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_Playlist: Could not get .spl playlist file.");
     close(fd);
     LIBMTP_INFO("FIXME closed\n");
+    return;
   }
 
   text_t* p = read_into_spl_text_t(device, fd);
@@ -219,6 +225,10 @@ int playlist_t_to_spl(LIBMTP_mtpdevice_t *device,
 
   // create the file object for storing
   LIBMTP_file_t* f = malloc(sizeof(LIBMTP_file_t));
+  if (f == NULL) {
+    LIBMTP_ERROR("f malloc failed");
+    return -1;
+  }
   f->item_id = 0;
   f->parent_id = pl->parent_id;
   f->storage_id = pl->storage_id;
@@ -838,11 +848,21 @@ static uint32_t find_folder_id(LIBMTP_folder_t* folders, uint32_t parent, char*
  */
 static void append_text_t(text_t** t, char* s)
 {
+  if (s == NULL)
+    return;
+
   if(*t == NULL) {
     *t = malloc(sizeof(text_t));
+
+    if (*t == NULL)
+      return;
   }
   else {
     (*t)->next = malloc(sizeof(text_t));
+
+    if ((*t)->next == NULL)
+      return;
+
     (*t) = (*t)->next;
   }
   (*t)->text = strdup(s);