From: Kitae Kim Date: Wed, 14 Jan 2015 09:45:04 +0000 (+0900) Subject: improve error cases X-Git-Tag: accepted/tizen/common/20150529.082331~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cfbf2c98d0031b93a40fcbf423128d9d72b4267;p=platform%2Fadaptation%2Femulator%2Fgst-plugins-emulator.git improve error cases - null pointer dereferences - uninitialize variables Change-Id: Idfc6f59cc12ef4cf32c61b2c43131a8040499f97 Signed-off-by: Kitae Kim --- diff --git a/src/gstmarudec.c b/src/gstmarudec.c index cf22547..e40dff8 100644 --- a/src/gstmarudec.c +++ b/src/gstmarudec.c @@ -357,7 +357,7 @@ gst_marudec_base_init (GstMaruDecClass *klass) longname, classification, description, - "Kitae Kim "); + "Erik Walthinsen "); 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); diff --git a/src/gstmarudevice.c b/src/gstmarudevice.c index 3e00b74..8de3c5b 100644 --- a/src/gstmarudevice.c +++ b/src/gstmarudevice.c @@ -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);