add free routine for svace issue. 84/125884/1 accepted/tizen/unified/20170419.165359 submit/tizen/20170419.082528 tizen_4.0.m1_release
authorHyihong Chae <hh.chae@samsung.com>
Wed, 19 Apr 2017 08:06:30 +0000 (17:06 +0900)
committerHyihong Chae <hh.chae@samsung.com>
Wed, 19 Apr 2017 08:06:30 +0000 (17:06 +0900)
Change-Id: Iffe05fadb4b53d85922d8ad6537e59367560adae
Signed-off-by: HyiHong Chae <hh.chae@samsung.com>
src/libusb1-glue.c

index 212edcd..fb0113d 100755 (executable)
@@ -914,8 +914,7 @@ ptp_read_func (
                          CONTEXT_BLOCK_SIZE,
                                                                  &xread,
                          ptp_usb->timeout);
-    }
-    else {
+    } else {
         ret = USB_BULK_READ(ptp_usb->handle,
                           ptp_usb->inep,
                           bytes,
@@ -946,8 +945,10 @@ ptp_read_func (
     }
 
     int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes, &written);
-    if (putfunc_ret != PTP_RC_OK)
+    if (putfunc_ret != PTP_RC_OK) {
+      free(bytes);
       return putfunc_ret;
+    }
 
     ptp_usb->current_transfer_complete += xread;
     curread += xread;
@@ -955,18 +956,19 @@ ptp_read_func (
     // Increase counters, call callback
     if (ptp_usb->callback_active) {
       if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
-       // send last update and disable callback.
-       ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
-       ptp_usb->callback_active = 0;
+        // send last update and disable callback.
+        ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
+        ptp_usb->callback_active = 0;
       }
       if (ptp_usb->current_transfer_callback != NULL) {
-       int ret;
-       ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
-                                                ptp_usb->current_transfer_total,
-                                                ptp_usb->current_transfer_callback_data);
-       if (ret != 0) {
-         return PTP_ERROR_CANCEL;
-       }
+        int ret;
+        ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
+                             ptp_usb->current_transfer_total,
+                             ptp_usb->current_transfer_callback_data);
+        if (ret != 0) {
+          free(bytes);
+          return PTP_ERROR_CANCEL;
+        }
       }
     }
 
@@ -1046,7 +1048,7 @@ ptp_write_func (
            LIBMTP_USB_DEBUG("USB OUT==>\n");
 
            if (ret != LIBUSB_SUCCESS) {
-              free(bytes);
+          free(bytes);
              return PTP_ERROR_IO;
            }
            LIBMTP_USB_DATA(bytes+usbwritten, xwritten, 16);
@@ -1059,19 +1061,19 @@ ptp_write_func (
     // call callback
     if (ptp_usb->callback_active) {
       if (ptp_usb->current_transfer_complete >= ptp_usb->current_transfer_total) {
-       // send last update and disable callback.
-       ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
-       ptp_usb->callback_active = 0;
+        // send last update and disable callback.
+        ptp_usb->current_transfer_complete = ptp_usb->current_transfer_total;
+        ptp_usb->callback_active = 0;
       }
       if (ptp_usb->current_transfer_callback != NULL) {
-       int ret;
-       ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
-                                                ptp_usb->current_transfer_total,
-                                                ptp_usb->current_transfer_callback_data);
-       if (ret != 0) {
+        int ret;
+        ret = ptp_usb->current_transfer_callback(ptp_usb->current_transfer_complete,
+                             ptp_usb->current_transfer_total,
+                             ptp_usb->current_transfer_callback_data);
+        if (ret != 0) {
           free(bytes);
-         return PTP_ERROR_CANCEL;
-       }
+          return PTP_ERROR_CANCEL;
+        }
       }
     }
     if (xwritten < towrite) /* short writes happen */