[vlc-devel] commit: Kill a few warnings about unchecked asprintf() return values. I'm ( JP Dinger )
git version control
git at videolan.org
Tue Nov 17 09:53:16 CET 2009
vlc | branch: master | JP Dinger <jpd at videolan.org> | Mon Nov 16 22:53:34 2009 +0100| [c240b3d3f74b6e542c3d2e3d3f0b7ff52b14842a] | committer: JP Dinger
Kill a few warnings about unchecked asprintf() return values. I'm
assuming TAB_APPEND will know what to do with a NULL string ptr
as opposed to an undefined one.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c240b3d3f74b6e542c3d2e3d3f0b7ff52b14842a
---
modules/control/http/http.c | 41 ++++++++++++++++++++++++++++-------------
1 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/modules/control/http/http.c b/modules/control/http/http.c
index 4494f7e..fe043e9 100644
--- a/modules/control/http/http.c
+++ b/modules/control/http/http.c
@@ -583,33 +583,40 @@ int HandlerCallback( httpd_handler_sys_t *p_args,
if( i_request )
{
- asprintf( &psz_tmp, "QUERY_STRING=%s", p_request );
+ if( -1==asprintf( &psz_tmp, "QUERY_STRING=%s", p_request ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
- asprintf( &psz_tmp, "REQUEST_URI=%s?%s", p_url, p_request );
+ if( -1==asprintf( &psz_tmp, "REQUEST_URI=%s?%s", p_url, p_request ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
else
{
- asprintf( &psz_tmp, "REQUEST_URI=%s", p_url );
+ if( -1==asprintf( &psz_tmp, "REQUEST_URI=%s", p_url ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
- asprintf( &psz_tmp, "SCRIPT_NAME=%s", p_url );
+ if( -1==asprintf( &psz_tmp, "SCRIPT_NAME=%s", p_url ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
#define p_sys p_args->file.p_intf->p_sys
- asprintf( &psz_tmp, "SERVER_NAME=%s", p_sys->psz_address );
+ if( -1==asprintf( &psz_tmp, "SERVER_NAME=%s", p_sys->psz_address ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
- asprintf( &psz_tmp, "SERVER_PORT=%u", p_sys->i_port );
+ if( -1==asprintf( &psz_tmp, "SERVER_PORT=%u", p_sys->i_port ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
#undef p_sys
p = getenv( "PATH" );
if( p != NULL )
{
- asprintf( &psz_tmp, "PATH=%s", p );
+ if( -1==asprintf( &psz_tmp, "PATH=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
@@ -617,20 +624,23 @@ int HandlerCallback( httpd_handler_sys_t *p_args,
p = getenv( "windir" );
if( p != NULL )
{
- asprintf( &psz_tmp, "SYSTEMROOT=%s", p );
+ if( -1==asprintf( &psz_tmp, "SYSTEMROOT=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
#endif
if( psz_remote_addr != NULL && *psz_remote_addr )
{
- asprintf( &psz_tmp, "REMOTE_ADDR=%s", psz_remote_addr );
+ if( -1==asprintf( &psz_tmp, "REMOTE_ADDR=%s", psz_remote_addr ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
if( psz_remote_host != NULL && *psz_remote_host )
{
- asprintf( &psz_tmp, "REMOTE_HOST=%s", psz_remote_host );
+ if( -1==asprintf( &psz_tmp, "REMOTE_HOST=%s", psz_remote_host ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
}
@@ -645,7 +655,8 @@ int HandlerCallback( httpd_handler_sys_t *p_args,
if( end == NULL )
break;
*end = '\0';
- asprintf( &psz_tmp, "CONTENT_TYPE=%s", p );
+ if( -1==asprintf( &psz_tmp, "CONTENT_TYPE=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
*end = '\r';
}
@@ -656,7 +667,8 @@ int HandlerCallback( httpd_handler_sys_t *p_args,
if( end == NULL )
break;
*end = '\0';
- asprintf( &psz_tmp, "CONTENT_LENGTH=%s", p );
+ if( -1==asprintf( &psz_tmp, "CONTENT_LENGTH=%s", p ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
*end = '\r';
}
@@ -675,7 +687,8 @@ int HandlerCallback( httpd_handler_sys_t *p_args,
if( psz_file != NULL )
{
psz_file++;
- asprintf( &psz_tmp, "SCRIPT_FILENAME=%s", psz_file );
+ if( -1==asprintf( &psz_tmp, "SCRIPT_FILENAME=%s", psz_file ) )
+ psz_tmp = NULL;
TAB_APPEND( i_env, ppsz_env, psz_tmp );
TAB_APPEND( p_args->p_association->i_argc,
@@ -819,6 +832,8 @@ int ArtCallback( httpd_handler_sys_t *p_args,
i_header_size = asprintf( &psz_header, HEADER, psz_ext, i_data );
#undef HEADER
+ assert( i_header_size != -1 );
+
*pi_data = i_header_size + i_data;
*pp_data = (uint8_t*)malloc( *pi_data );
memcpy( *pp_data, psz_header, i_header_size );
More information about the vlc-devel
mailing list