improve error cases 53/33753/1
authorKitae Kim <kt920.kim@samsung.com>
Wed, 14 Jan 2015 09:45:04 +0000 (18:45 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Wed, 14 Jan 2015 09:45:27 +0000 (18:45 +0900)
- null pointer dereferences
- uninitialize variables

Change-Id: Idfc6f59cc12ef4cf32c61b2c43131a8040499f97
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
src/gstmarudec.c
src/gstmarudevice.c

index cf22547..e40dff8 100644 (file)
@@ -357,7 +357,7 @@ gst_marudec_base_init (GstMaruDecClass *klass)
             longname,
             classification,
             description,
-            "Kitae Kim <kt920.kim@samsung.com>");
+            "Erik Walthinsen <omega@cse.ogi.edu>");
 
   g_free (longname);
   g_free (classification);
@@ -504,6 +504,9 @@ gst_marudec_sink_event (GstPad *pad, GstEvent *event)
   gboolean ret = FALSE;
 
   marudec = (GstMaruDec *) gst_pad_get_parent (pad);
+  if (!marudec) {
+    return FALSE;
+  }
 
   GST_DEBUG_OBJECT (marudec, "Handling %s event",
     GST_EVENT_TYPE_NAME (event));
@@ -616,6 +619,10 @@ gst_marudec_setcaps (GstPad *pad, GstCaps *caps)
   GST_DEBUG_OBJECT (pad, "setcaps called.");
 
   marudec = (GstMaruDec *) (gst_pad_get_parent (pad));
+  if (!marudec) {
+    return FALSE;
+  }
+
   oclass = (GstMaruDecClass *) (G_OBJECT_GET_CLASS (marudec));
 
   GST_OBJECT_LOCK (marudec);
index 3e00b74..8de3c5b 100644 (file)
@@ -153,20 +153,20 @@ gst_maru_avcodec_open (CodecContext *ctx,
 int
 gst_maru_avcodec_close (CodecContext *ctx, CodecDevice *dev)
 {
-  int ret;
-
-  GST_DEBUG ("close %d of context", ctx->index);
+  int ret = 0;
 
-  if (ctx && ctx->index == 0) {
-    GST_INFO ("context is not opened yet or context before %d", ctx->index);
+  if (!ctx || (ctx->index == 0)) {
+    GST_INFO ("context is null or closed before");
     return -1;
   }
 
-  if (dev && dev->fd < 0) {
-    GST_INFO ("fd is not opened yet or closed before %d", dev->fd);
+  if (!dev || (dev->fd < 0)) {
+    GST_INFO ("dev is null or fd is closed before");
     return -1;
   }
 
+  GST_DEBUG ("close %d of context", ctx->index);
+
   g_mutex_lock (&gst_avcodec_mutex);
   interface->deinit (ctx, dev);
   g_mutex_unlock (&gst_avcodec_mutex);