From c116d7baa5c67e19cf9dab7f0fe4eab4a1c41898 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Sun, 7 Jan 2001 03:06:28 +0000 Subject: [PATCH] fixed a bug with NULL args, but need to fix the parser that created them Original commit message from CVS: fixed a bug with NULL args, but need to fix the parser that created them --- tools/gstreamer-launch.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/gstreamer-launch.c b/tools/gstreamer-launch.c index 7abfd23580..cf368da212 100644 --- a/tools/gstreamer-launch.c +++ b/tools/gstreamer-launch.c @@ -79,6 +79,8 @@ gint parse_cmdline(int argc,char *argv[],GstBin *parent) { while (i < argc) { arg = argv[i]; + // FIXME this is a lame solution for problems with the first parser + if (arg == NULL) { i++;continue; } len = strlen(arg); element = NULL; DEBUG("** ARGUMENT is '%s'\n",arg); @@ -166,10 +168,18 @@ gint parse_cmdline(int argc,char *argv[],GstBin *parent) { if (arg[0] == '(') { // create a bin and add it to the current parent element = gst_bin_new(g_strdup_printf("bin%d",bincount++)); + if (!element) { + fprintf(stderr,"Couldn't create a bin!\n"); + exit(-1); + } VERBOSE("CREATED bin %s\n",gst_element_get_name(element)); } else if (arg[0] == '{') { // create a thread and add it to the current parent element = gst_thread_new(g_strdup_printf("thread%d",threadcount++)); + if (!element) { + fprintf(stderr,"Couldn't create a thread!\n"); + exit(-1); + } VERBOSE("CREATED thread %s\n",gst_element_get_name(element)); } @@ -179,6 +189,10 @@ gint parse_cmdline(int argc,char *argv[],GstBin *parent) { // we have an element DEBUG("attempting to create element '%s'\n",arg); element = gst_elementfactory_make(arg,unique_name(arg)); + if (!element) { + fprintf(stderr,"Couldn't create a '%s', no such element or need to run gstraemer-register?\n",arg); + exit(-1); + } VERBOSE("CREATED element %s\n",gst_element_get_name(element)); DEBUG("created element %s\n",gst_element_get_name(element)); } @@ -334,7 +348,6 @@ gint parse(int argc,char *argv[],GstBin *parent) { int main(int argc,char *argv[]) { GstElement *pipeline; int firstarg; - guint i; gst_init(&argc,&argv);