Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
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 )
...
@@ -429,14 +429,12 @@ rtmp_connect_active( rtmp_control_thread_t *p_thread )
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"file:///mac.flv"
)
);
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"file:///mac.flv"
)
);
free
(
tmp_buffer
);
free
(
tmp_buffer
);
tmp_url
=
(
char
*
)
malloc
(
strlen
(
"rtmp://"
)
+
strlen
(
p_thread
->
url
.
psz_buffer
)
+
1
);
if
(
asprintf
(
&
tmp_url
,
"rtmp://%s"
,
p_thread
->
url
.
psz_buffer
)
==
-
1
)
if
(
!
tmp_url
)
{
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
free
(
rtmp_body
);
return
-
1
;
return
-
1
;
}
}
sprintf
(
tmp_url
,
"rtmp://%s"
,
p_thread
->
url
.
psz_buffer
);
tmp_buffer
=
amf_encode_object_variable
(
"tcUrl"
,
tmp_buffer
=
amf_encode_object_variable
(
"tcUrl"
,
AMF_DATATYPE_STRING
,
tmp_url
);
AMF_DATATYPE_STRING
,
tmp_url
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
...
@@ -1858,14 +1856,12 @@ rtmp_encode_NetStream_play_reset_onStatus( rtmp_control_thread_t *p_thread, char
...
@@ -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"
)
);
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"NetStream.Play.Reset"
)
);
free
(
tmp_buffer
);
free
(
tmp_buffer
);
description
=
(
char
*
)
malloc
(
strlen
(
"Playing and resetting "
)
+
strlen
(
psz_media
)
+
strlen
(
"."
)
+
1
);
if
(
asprintf
(
&
description
,
"Playing and resetting %s."
,
psz_media
)
==
-
1
)
if
(
!
description
)
{
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
free
(
rtmp_body
);
return
NULL
;
return
NULL
;
}
}
sprintf
(
description
,
"Playing and resetting %s."
,
psz_media
);
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
AMF_DATATYPE_STRING
,
description
);
AMF_DATATYPE_STRING
,
description
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
...
@@ -1944,15 +1940,13 @@ rtmp_encode_NetStream_play_start_onStatus( rtmp_control_thread_t *p_thread, char
...
@@ -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"
)
);
AMF_DATATYPE_SIZE_STRING
+
strlen
(
"NetStream.Play.Start"
)
);
free
(
tmp_buffer
);
free
(
tmp_buffer
);
description
=
(
char
*
)
malloc
(
strlen
(
"Started playing "
)
+
strlen
(
psz_media
)
+
strlen
(
"."
)
+
1
);
if
(
asprintf
(
&
description
,
"Started playing %s."
,
psz_media
)
==
-
1
)
if
(
!
description
)
{
{
free
(
rtmp_body
->
body
);
free
(
rtmp_body
->
body
);
free
(
rtmp_body
);
free
(
rtmp_body
);
return
NULL
;
return
NULL
;
}
}
sprintf
(
description
,
"Started playing %s."
,
psz_media
);
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
tmp_buffer
=
amf_encode_object_variable
(
"description"
,
AMF_DATATYPE_STRING
,
description
);
AMF_DATATYPE_STRING
,
description
);
rtmp_body_append
(
rtmp_body
,
tmp_buffer
,
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,
...
@@ -846,8 +846,8 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
}
}
else
else
{
{
psz_cuefile
=
malloc
(
strlen
(
psz_dev
)
+
5
/* ".cue" */
);
if
(
asprintf
(
&
psz_cuefile
,
"%s.cue"
,
psz_dev
)
==
-
1
)
sprintf
(
psz_cuefile
,
"%s.cue"
,
psz_dev
)
;
psz_cuefile
=
NULL
;
}
}
/* If we need to look up the .cue file, then we don't have to look for the vcd */
/* If we need to look up the .cue file, then we don't have to look for the vcd */
psz_vcdfile
=
strdup
(
psz_dev
);
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,
...
@@ -587,11 +587,10 @@ static void MacroDo( httpd_file_sys_t *p_args,
}
}
else
else
{
{
vlm_error
=
malloc
(
strlen
(
vlm_answer
->
psz_name
)
+
if
(
asprintf
(
&
vlm_error
,
"%s : %s"
,
strlen
(
vlm_answer
->
psz_value
)
+
vlm_answer
->
psz_name
,
strlen
(
" : "
)
+
1
);
vlm_answer
->
psz_value
)
==
-
1
)
sprintf
(
vlm_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_error
=
NULL
;
vlm_answer
->
psz_value
);
}
}
mvar_AppendNewVar
(
p_args
->
vars
,
"vlm_error"
,
vlm_error
);
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,
...
@@ -1087,9 +1087,9 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
while
(
strcmp
(
psz_elt
=
SSPop
(
st
),
""
)
while
(
strcmp
(
psz_elt
=
SSPop
(
st
),
""
)
&&
strcmp
(
psz_elt
,
";"
)
)
&&
strcmp
(
psz_elt
,
";"
)
)
{
{
char
*
psz_buf
=
char
*
psz_buf
;
(
char
*
)
malloc
(
strlen
(
psz_cmd
)
+
strlen
(
psz_elt
)
+
2
);
if
(
asprintf
(
&
psz_buf
,
"%s %s"
,
psz_cmd
,
psz_elt
)
==
-
1
)
sprintf
(
psz_buf
,
"%s %s"
,
psz_cmd
,
psz_elt
)
;
psz_buf
=
NULL
;
free
(
psz_cmd
);
free
(
psz_cmd
);
free
(
psz_elt
);
free
(
psz_elt
);
psz_cmd
=
psz_buf
;
psz_cmd
=
psz_buf
;
...
@@ -1104,11 +1104,9 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
...
@@ -1104,11 +1104,9 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
}
}
else
else
{
{
psz_error
=
malloc
(
strlen
(
vlm_answer
->
psz_name
)
+
if
(
asprintf
(
&
psz_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
strlen
(
vlm_answer
->
psz_value
)
+
vlm_answer
->
psz_value
)
==
-
1
)
strlen
(
" : "
)
+
1
);
psz_error
=
NULL
;
sprintf
(
psz_error
,
"%s : %s"
,
vlm_answer
->
psz_name
,
vlm_answer
->
psz_value
);
}
}
mvar_AppendNewVar
(
vars
,
"vlm_error"
,
psz_error
);
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 )
...
@@ -315,11 +315,10 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
*
psz_parser
=
'\0'
;
*
psz_parser
=
'\0'
;
psz_parser
++
;
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
;
intf_thread_t
*
p_new_intf
;
sprintf
(
psz_temp
,
"%s,none"
,
psz_module
);
/* Try to create the interface */
/* Try to create the interface */
p_new_intf
=
intf_Create
(
p_intf
,
psz_temp
);
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 )
...
@@ -604,7 +604,6 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
p_seg
=
used_segments
[
i
];
p_seg
=
used_segments
[
i
];
if
(
p_seg
->
p_editions
!=
NULL
)
if
(
p_seg
->
p_editions
!=
NULL
)
{
{
std
::
string
sz_name
;
input_title_t
*
p_title
=
vlc_input_title_New
();
input_title_t
*
p_title
=
vlc_input_title_New
();
p_seg
->
i_sys_title
=
i
;
p_seg
->
i_sys_title
=
i
;
int
i_chapters
;
int
i_chapters
;
...
@@ -614,9 +613,9 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
...
@@ -614,9 +613,9 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
{
{
if
(
p_title
->
psz_name
==
NULL
)
if
(
p_title
->
psz_name
==
NULL
)
{
{
sz_name
=
(
*
p_seg
->
p_editions
)[
j
]
->
GetMainName
();
const
char
*
psz_tmp
=
(
*
p_seg
->
p_editions
)[
j
]
->
GetMainName
().
c_str
();
if
(
sz_name
!=
""
)
if
(
*
psz_tmp
!=
'\0'
)
p_title
->
psz_name
=
strdup
(
sz_name
.
c_str
()
);
p_title
->
psz_name
=
strdup
(
psz_tmp
);
}
}
chapter_edition_c
*
p_edition
=
(
*
p_seg
->
p_editions
)[
j
];
chapter_edition_c
*
p_edition
=
(
*
p_seg
->
p_editions
)[
j
];
...
@@ -628,11 +627,8 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
...
@@ -628,11 +627,8 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
// create a name if there is none
// create a name if there is none
if
(
p_title
->
psz_name
==
NULL
)
if
(
p_title
->
psz_name
==
NULL
)
{
{
sz_name
=
N_
(
"Segment"
);
if
(
asprintf
(
&
(
p_title
->
psz_name
),
"%s %d"
,
N_
(
"Segment"
),
(
int
)
i
)
==
-
1
)
char
psz_str
[
6
];
p_title
->
psz_name
=
NULL
;
sprintf
(
psz_str
,
" %d"
,
(
int
)
i
);
sz_name
+=
psz_str
;
p_title
->
psz_name
=
strdup
(
sz_name
.
c_str
()
);
}
}
titles
.
push_back
(
p_title
);
titles
.
push_back
(
p_title
);
...
...
modules/demux/playlist/gvp.c
View file @
0237be20
...
@@ -178,9 +178,8 @@ static int Demux( demux_t *p_demux )
...
@@ -178,9 +178,8 @@ static int Demux( demux_t *p_demux )
else
else
{
{
/* handle multi-line descriptions */
/* handle multi-line descriptions */
buf
=
malloc
(
strlen
(
psz_description
)
if
(
asprintf
(
&
buf
,
"%s
\n
%s"
,
psz_description
,
psz_attrvalue
)
==
-
1
)
+
strlen
(
psz_attrvalue
)
+
2
);
buf
=
NULL
;
sprintf
(
buf
,
"%s
\n
%s"
,
psz_description
,
psz_attrvalue
);
free
(
psz_description
);
free
(
psz_description
);
psz_description
=
buf
;
psz_description
=
buf
;
}
}
...
...
modules/demux/playlist/shoutcast.c
View file @
0237be20
...
@@ -388,19 +388,16 @@ static int DemuxStation( demux_t *p_demux )
...
@@ -388,19 +388,16 @@ static int DemuxStation( demux_t *p_demux )
if
(
psz_rt
||
psz_load
)
if
(
psz_rt
||
psz_load
)
{
{
/* tv */
/* tv */
psz_mrl
=
malloc
(
strlen
(
SHOUTCAST_TV_TUNEIN_URL
)
if
(
asprintf
(
&
psz_mrl
,
SHOUTCAST_TV_TUNEIN_URL
"%s"
,
+
strlen
(
psz_id
)
+
1
);
psz_id
)
==
-
1
)
sprintf
(
psz_mrl
,
SHOUTCAST_TV_TUNEIN_URL
"%s"
,
psz_mrl
=
NULL
;
psz_id
);
}
}
else
else
{
{
/* radio */
/* radio */
psz_mrl
=
malloc
(
strlen
(
SHOUTCAST_TUNEIN_BASE_URL
)
if
(
asprintf
(
&
psz_mrl
,
SHOUTCAST_TUNEIN_BASE_URL
"%s?id=%s"
,
+
strlen
(
psz_base
)
+
strlen
(
"?id="
)
psz_base
,
psz_id
)
==
-
1
)
+
strlen
(
psz_id
)
+
1
);
psz_mrl
=
NULL
;
sprintf
(
psz_mrl
,
SHOUTCAST_TUNEIN_BASE_URL
"%s?id=%s"
,
psz_base
,
psz_id
);
}
}
p_input
=
input_item_NewExt
(
p_demux
,
psz_mrl
,
p_input
=
input_item_NewExt
(
p_demux
,
psz_mrl
,
psz_name
,
0
,
NULL
,
-
1
);
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 )
...
@@ -778,12 +778,9 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
case
' '
:
case
' '
:
if
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
b_file
||
i_key
==
' '
)
if
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
b_file
||
i_key
==
' '
)
{
{
int
i_size_entry
=
strlen
(
"directory://"
)
+
char
*
psz_uri
;
strlen
(
p_sys
->
psz_current_dir
)
+
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
)
strlen
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
+
2
;
psz_uri
=
NULL
;
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
);
playlist_item_t
*
p_parent
=
p_sys
->
p_node
;
playlist_item_t
*
p_parent
=
p_sys
->
p_node
;
if
(
!
p_parent
)
if
(
!
p_parent
)
...
@@ -805,15 +802,9 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
...
@@ -805,15 +802,9 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
}
}
else
else
{
{
int
i_size_entry
=
strlen
(
p_sys
->
psz_current_dir
)
+
if
(
asprintf
(
&
(
p_sys
->
psz_current_dir
),
"%s/%s"
,
p_sys
->
psz_current_dir
,
strlen
(
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
+
2
;
p_sys
->
pp_dir_entries
[
p_sys
->
i_box_bidx
]
->
psz_path
)
!=
-
1
)
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
);
ReadDir
(
p_intf
);
ReadDir
(
p_intf
);
free
(
psz_uri
);
}
}
break
;
break
;
default:
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