Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
0237be20
Commit
0237be20
authored
Oct 31, 2008
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use asprintf instead of malloc+sprintf.
parent
d329a269
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
63 deletions
+36
-63
modules/access/rtmp/rtmp_amf_flv.c
modules/access/rtmp/rtmp_amf_flv.c
+3
-9
modules/access/vcd/cdrom.c
modules/access/vcd/cdrom.c
+2
-2
modules/control/http/macro.c
modules/control/http/macro.c
+4
-5
modules/control/http/rpn.c
modules/control/http/rpn.c
+6
-8
modules/control/ntservice.c
modules/control/ntservice.c
+2
-3
modules/demux/mkv/demux.cpp
modules/demux/mkv/demux.cpp
+5
-9
modules/demux/playlist/gvp.c
modules/demux/playlist/gvp.c
+2
-3
modules/demux/playlist/shoutcast.c
modules/demux/playlist/shoutcast.c
+6
-9
modules/gui/ncurses.c
modules/gui/ncurses.c
+6
-15
No files found.
modules/access/rtmp/rtmp_amf_flv.c
View file @
0237be20
...
...
@@ -429,14 +429,12 @@ rtmp_connect_active( rtmp_control_thread_t *p_thread )
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"file:///mac.flv"
)
);
free
(
tmp_buffer
);
tmp_url
=
(
char
*
)
malloc
(
strlen
(
"rtmp://"
)
+
strlen
(
p_thread
->
url
.
psz_buffer
)
+
1
);
if
(
!
tmp_url
)
if
(
asprintf
(
&
tmp_url
,
"rtmp://%s"
,
p_thread
->
url
.
psz_buffer
)
==
-
1
)
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
return
-
1
;
}
sprintf
(
tmp_url
,
"rtmp://%s"
,
p_thread
->
url
.
psz_buffer
);
tmp_buffer
=
amf_encode_object_variable
(
"tcUrl"
,
AMF_DATATYPE_STRING
,
tmp_url
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
...
...
@@ -1858,14 +1856,12 @@ rtmp_encode_NetStream_play_reset_onStatus( rtmp_control_thread_t *p_thread, char
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"NetStream.Play.Reset"
)
);
free
(
tmp_buffer
);
description
=
(
char
*
)
malloc
(
strlen
(
"Playing and resetting "
)
+
strlen
(
psz_media
)
+
strlen
(
"."
)
+
1
);
if
(
!
description
)
if
(
asprintf
(
&
description
,
"Playing and resetting %s."
,
psz_media
)
==
-
1
)
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
return
NULL
;
}
sprintf
(
description
,
"Playing and resetting %s."
,
psz_media
);
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
AMF_DATATYPE_STRING
,
description
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
...
...
@@ -1944,15 +1940,13 @@ rtmp_encode_NetStream_play_start_onStatus( rtmp_control_thread_t *p_thread, char
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"NetStream.Play.Start"
)
);
free
(
tmp_buffer
);
description
=
(
char
*
)
malloc
(
strlen
(
"Started playing "
)
+
strlen
(
psz_media
)
+
strlen
(
"."
)
+
1
);
if
(
!
description
)
if
(
asprintf
(
&
description
,
"Started playing %s."
,
psz_media
)
==
-
1
)
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
return
NULL
;
}
sprintf
(
description
,
"Started playing %s."
,
psz_media
);
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
AMF_DATATYPE_STRING
,
description
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
...
...
modules/access/vcd/cdrom.c
View file @
0237be20
...
...
@@ -846,8 +846,8 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
}
else
{
psz_cuefile
=
malloc
(
strlen
(
psz_dev
)
+
5
/* ".cue" */
);
sprintf
(
psz_cuefile
,
"%s.cue"
,
psz_dev
)
;
if
(
asprintf
(
&
psz_cuefile
,
"%s.cue"
,
psz_dev
)
==
-
1
)
psz_cuefile
=
NULL
;
}
/* If we need to look up the .cue file, then we don't have to look for the vcd */
psz_vcdfile
=
strdup
(
psz_dev
);
...
...
modules/control/http/macro.c
View file @
0237be20
...
...
@@ -587,11 +587,10 @@ static void MacroDo( httpd_file_sys_t *p_args,
}
else
{
vlm_error
=
malloc
(
strlen
(
vlm_answer
->
psz_name
)
+
strlen
(
vlm_answer
->
psz_value
)
+
strlen
(
" : "
)
+
1
);
sprintf
(
vlm_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_answer
->
psz_value
);
if
(
asprintf
(
&
vlm_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_answer
->
psz_value
)
==
-
1
)
vlm_error
=
NULL
;
}
mvar_AppendNewVar
(
p_args
->
vars
,
"vlm_error"
,
vlm_error
);
...
...
modules/control/http/rpn.c
View file @
0237be20
...
...
@@ -1087,9 +1087,9 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
while
(
strcmp
(
psz_elt
=
SSPop
(
st
),
""
)
&&
strcmp
(
psz_elt
,
";"
)
)
{
char
*
psz_buf
=
(
char
*
)
malloc
(
strlen
(
psz_cmd
)
+
strlen
(
psz_elt
)
+
2
);
sprintf
(
psz_buf
,
"%s %s"
,
psz_cmd
,
psz_elt
)
;
char
*
psz_buf
;
if
(
asprintf
(
&
psz_buf
,
"%s %s"
,
psz_cmd
,
psz_elt
)
==
-
1
)
psz_buf
=
NULL
;
free
(
psz_cmd
);
free
(
psz_elt
);
psz_cmd
=
psz_buf
;
...
...
@@ -1104,11 +1104,9 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
}
else
{
psz_error
=
malloc
(
strlen
(
vlm_answer
->
psz_name
)
+
strlen
(
vlm_answer
->
psz_value
)
+
strlen
(
" : "
)
+
1
);
sprintf
(
psz_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_answer
->
psz_value
);
if
(
asprintf
(
&
psz_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_answer
->
psz_value
)
==
-
1
)
psz_error
=
NULL
;
}
mvar_AppendNewVar
(
vars
,
"vlm_error"
,
psz_error
);
...
...
modules/control/ntservice.c
View file @
0237be20
...
...
@@ -315,11 +315,10 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
*
psz_parser
=
'\0'
;
psz_parser
++
;
}
psz_temp
=
(
char
*
)
malloc
(
strlen
(
psz_module
)
+
sizeof
(
",none"
)
);
if
(
psz_temp
)
if
(
asprintf
(
&
psz_temp
,
"%s,none"
,
psz_module
)
!=
-
1
)
{
intf_thread_t
*
p_new_intf
;
sprintf
(
psz_temp
,
"%s,none"
,
psz_module
);
/* Try to create the interface */
p_new_intf
=
intf_Create
(
p_intf
,
psz_temp
);
...
...
modules/demux/mkv/demux.cpp
View file @
0237be20
...
...
@@ -604,7 +604,6 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
p_seg
=
used_segments
[
i
];
if
(
p_seg
->
p_editions
!=
NULL
)
{
std
::
string
sz_name
;
input_title_t
*
p_title
=
vlc_input_title_New
();
p_seg
->
i_sys_title
=
i
;
int
i_chapters
;
...
...
@@ -614,9 +613,9 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
{
if
(
p_title
->
psz_name
==
NULL
)
{
sz_name
=
(
*
p_seg
->
p_editions
)[
j
]
->
GetMainName
();
if
(
sz_name
!=
""
)
p_title
->
psz_name
=
strdup
(
sz_name
.
c_str
()
);
const
char
*
psz_tmp
=
(
*
p_seg
->
p_editions
)[
j
]
->
GetMainName
().
c_str
();
if
(
*
psz_tmp
!=
'\0'
)
p_title
->
psz_name
=
strdup
(
psz_tmp
);
}
chapter_edition_c
*
p_edition
=
(
*
p_seg
->
p_editions
)[
j
];
...
...
@@ -628,11 +627,8 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
// create a name if there is none
if
(
p_title
->
psz_name
==
NULL
)
{
sz_name
=
N_
(
"Segment"
);
char
psz_str
[
6
];
sprintf
(
psz_str
,
" %d"
,
(
int
)
i
);
sz_name
+=
psz_str
;
p_title
->
psz_name
=
strdup
(
sz_name
.
c_str
()
);
if
(
asprintf
(
&
(
p_title
->
psz_name
),
"%s %d"
,
N_
(
"Segment"
),
(
int
)
i
)
==
-
1
)
p_title
->
psz_name
=
NULL
;
}
titles
.
push_back
(
p_title
);
...
...
modules/demux/playlist/gvp.c
View file @
0237be20
...
...
@@ -178,9 +178,8 @@ static int Demux( demux_t *p_demux )
else
{
/* handle multi-line descriptions */
buf
=
malloc
(
strlen
(
psz_description
)
+
strlen
(
psz_attrvalue
)
+
2
);
sprintf
(
buf
,
"%s
\n
%s"
,
psz_description
,
psz_attrvalue
);
if
(
asprintf
(
&
buf
,
"%s
\n
%s"
,
psz_description
,
psz_attrvalue
)
==
-
1
)
buf
=
NULL
;
free
(
psz_description
);
psz_description
=
buf
;
}
...
...
modules/demux/playlist/shoutcast.c
View file @
0237be20
...
...
@@ -388,19 +388,16 @@ static int DemuxStation( demux_t *p_demux )
if
(
psz_rt
||
psz_load
)
{
/* tv */
psz_mrl
=
malloc
(
strlen
(
SHOUTCAST_TV_TUNEIN_URL
)
+
strlen
(
psz_id
)
+
1
);
sprintf
(
psz_mrl
,
SHOUTCAST_TV_TUNEIN_URL
"%s"
,
psz_id
);
if
(
asprintf
(
&
psz_mrl
,
SHOUTCAST_TV_TUNEIN_URL
"%s"
,
psz_id
)
==
-
1
)
psz_mrl
=
NULL
;
}
else
{
/* radio */
psz_mrl
=
malloc
(
strlen
(
SHOUTCAST_TUNEIN_BASE_URL
)
+
strlen
(
psz_base
)
+
strlen
(
"?id="
)
+
strlen
(
psz_id
)
+
1
);
sprintf
(
psz_mrl
,
SHOUTCAST_TUNEIN_BASE_URL
"%s?id=%s"
,
psz_base
,
psz_id
);
if
(
asprintf
(
&
psz_mrl
,
SHOUTCAST_TUNEIN_BASE_URL
"%s?id=%s"
,
psz_base
,
psz_id
)
==
-
1
)
psz_mrl
=
NULL
;
}
p_input
=
input_item_NewExt
(
p_demux
,
psz_mrl
,
psz_name
,
0
,
NULL
,
-
1
);
...
...
modules/gui/ncurses.c
View file @
0237be20
...
...
@@ -778,12 +778,9 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
case
' '
:
if
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
b_file
||
i_key
==
' '
)
{
int
i_size_entry
=
strlen
(
"directory://"
)
+
strlen
(
p_sys
->
psz_current_dir
)
+
strlen
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
+
2
;
char
*
psz_uri
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
i_size_entry
);
sprintf
(
psz_uri
,
"directory://%s/%s"
,
p_sys
->
psz_current_dir
,
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
);
char
*
psz_uri
;
if
(
asprintf
(
&
psz_uri
,
"directory://%s/%s"
,
p_sys
->
psz_current_dir
,
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
==
-
1
)
psz_uri
=
NULL
;
playlist_item_t
*
p_parent
=
p_sys
->
p_node
;
if
(
!
p_parent
)
...
...
@@ -805,15 +802,9 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
}
else
{
int
i_size_entry
=
strlen
(
p_sys
->
psz_current_dir
)
+
strlen
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
+
2
;
char
*
psz_uri
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
i_size_entry
);
sprintf
(
psz_uri
,
"%s/%s"
,
p_sys
->
psz_current_dir
,
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
);
p_sys
->
psz_current_dir
=
strdup
(
psz_uri
);
if
(
asprintf
(
&
(
p_sys
->
psz_current_dir
),
"%s/%s"
,
p_sys
->
psz_current_dir
,
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
!=
-
1
)
ReadDir
(
p_intf
);
free
(
psz_uri
);
}
break
;
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment