# HG changeset patch # User pl # Date 1008767002 0 # Node ID a1522fa7728a74534233a9d4eb5c24a86a2fbfde # Parent 178c562948ff40e63548a5ea3a5881516248f9fd x = malloc(strlen(s) + c) ... strcpy(x, s) replaced by x = strdup(s) Note: sometimes c was 0 and that was a bug Note2: code still has to be added to check the returned value of these funcs diff -r 178c562948ff -r a1522fa7728a libmpdemux/demux_viv.c --- a/libmpdemux/demux_viv.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/demux_viv.c Wed Dec 19 13:03:22 2001 +0000 @@ -191,26 +191,22 @@ if (!strcmp(opt, "Title")) { demux_info_add(demux, "name", param); - priv->title = malloc(strlen(param)); - strcpy(priv->title, param); + priv->title = strdup(param); } if (!strcmp(opt, "Author")) { demux_info_add(demux, "author", param); - priv->author = malloc(strlen(param)); - strcpy(priv->author, param); + priv->author = strdup(param); } if (!strcmp(opt, "Copyright")) { demux_info_add(demux, "copyright", param); - priv->copyright = malloc(strlen(param)); - strcpy(priv->copyright, param); + priv->copyright = strdup(param); } if (!strcmp(opt, "Producer")) { demux_info_add(demux, "encoder", param); - priv->producer = malloc(strlen(param)); - strcpy(priv->producer, param); + priv->producer = strdup(param); } /* get next token */ diff -r 178c562948ff -r a1522fa7728a libmpdemux/tv.c --- a/libmpdemux/tv.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/tv.c Wed Dec 19 13:03:22 2001 +0000 @@ -343,8 +343,7 @@ mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment); params = malloc(sizeof(tvi_param_t)*2); - params[0].opt = malloc(strlen("input")); - sprintf((char *)params[0].opt, "input"); + params[0].opt = strdup("input"); params[0].value = malloc(sizeof(int)); (int)*(void **)params[0].value = tv_param_input; params[1].opt = params[1].value = NULL; diff -r 178c562948ff -r a1522fa7728a libmpdemux/url.c --- a/libmpdemux/url.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/url.c Wed Dec 19 13:03:22 2001 +0000 @@ -29,12 +29,11 @@ memset( Curl, 0, sizeof(URL_t) ); // Copy the url in the URL container - Curl->url = (char*)malloc(strlen(url)+1); + Curl->url = strdup(url); if( Curl->url==NULL ) { printf("Memory allocation failed!\n"); return NULL; } - strcpy(Curl->url, url); // extract the protocol ptr1 = strstr(url, "://"); @@ -86,12 +85,11 @@ // check if it's not a trailing '/' if( strlen(ptr2)>1 ) { // copy the path/filename in the URL container - Curl->file = (char*)malloc(strlen(ptr2)+1); + Curl->file = strdup(ptr2); if( Curl->file==NULL ) { printf("Memory allocation failed!\n"); return NULL; } - strcpy(Curl->file, ptr2); } } // Check if a filenme was given or set, else set it with '/'