Add unmap buffer in error case 64/151864/2
authorSeokHoon Lee <andy.shlee@samsung.com>
Fri, 22 Sep 2017 07:39:40 +0000 (16:39 +0900)
committerSeokHoon Lee <andy.shlee@samsung.com>
Tue, 26 Sep 2017 05:22:39 +0000 (14:22 +0900)
- add gst_buffer_unmap in case of file open error.

Signed-off-by: SeokHoon Lee <andy.shlee@samsung.com>
Change-Id: I99e80b3e20beb82ef1028e788708909479876d9c

packaging/libmm-wfd.spec
src/mm_wfd_sink_util.c

index 04b854a..8df90d3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.2.230
+Version:    0.2.231
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index a5801b4..9093f63 100644 (file)
@@ -57,17 +57,19 @@ _mm_wfd_sink_util_dump(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
                GstMapInfo buf_info;
                GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
 
-               gst_buffer_map(buffer, &buf_info, GST_MAP_READ);
-
-               wfd_sink_debug("got buffer %p with size %d", buffer, buf_info.size);
-               data = (gint8 *)(buf_info.data);
-               size = buf_info.size;
                f = fopen(path, "a");
                if (f == NULL) {
                        strerror_r(errno, buf, sizeof(buf));
                        wfd_sink_error("failed to fopen! : %s", buf);
                        return GST_PAD_PROBE_OK;
                }
+
+               gst_buffer_map(buffer, &buf_info, GST_MAP_READ);
+
+               wfd_sink_debug("got buffer %p with size %d", buffer, buf_info.size);
+               data = (gint8 *)(buf_info.data);
+               size = buf_info.size;
+
                fwrite(data, size, 1, f);
                fclose(f);
                gst_buffer_unmap(buffer, &buf_info);