mirror of
https://github.com/mpv-player/mpv
synced 2024-09-05 02:48:21 +02:00
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 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3613 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
d8925752b8
commit
e0c43586ae
@ -191,26 +191,22 @@ static void vivo_parse_text_header(demuxer_t *demux, int header_len)
|
||||
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 */
|
||||
|
@ -343,8 +343,7 @@ int tv_init(tvi_handle_t *tvh)
|
||||
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;
|
||||
|
@ -29,12 +29,11 @@ url_new(char* url) {
|
||||
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 @@ url_new(char* url) {
|
||||
// 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 '/'
|
||||
|
Loading…
Reference in New Issue
Block a user