diff options
author | wm4 <wm4@nowhere> | 2012-11-01 00:32:17 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-01 02:12:17 +0100 |
commit | 2b35fc13eddb4cbad2422e53bb9be26df3dfc205 (patch) | |
tree | 8b02cdf594e8341d1ea01ef1791e21ff4d936bd9 /stream | |
parent | 73f866e7ebaf11f855d255649b5f57d6d19f541c (diff) | |
download | mpv-2b35fc13eddb4cbad2422e53bb9be26df3dfc205.tar.bz2 mpv-2b35fc13eddb4cbad2422e53bb9be26df3dfc205.tar.xz |
http: fix potential NULL pointer issue
Found by clang analyzer. This called strlen(NULL), if the uri field
in the http_hdr wasn't set. It seems all callers of this function set
the field properly, so remove the bogus fallback to "/".
Diffstat (limited to 'stream')
-rw-r--r-- | stream/http.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/stream/http.c b/stream/http.c index 61795bcf9b..e88b0bd468 100644 --- a/stream/http.c +++ b/stream/http.c @@ -463,21 +463,20 @@ http_response_parse( HTTP_header_t *http_hdr ) { char * http_build_request( HTTP_header_t *http_hdr ) { - char *ptr, *uri=NULL; + char *ptr, *uri; int len; HTTP_field_t *field; if( http_hdr==NULL ) return NULL; + if( http_hdr->uri==NULL ) return NULL; if( http_hdr->method==NULL ) http_set_method( http_hdr, "GET"); - if( http_hdr->uri==NULL ) http_set_uri( http_hdr, "/"); - else { - uri = malloc(strlen(http_hdr->uri) + 1); - if( uri==NULL ) { - mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n"); - return NULL; - } - strcpy(uri,http_hdr->uri); - } + + uri = malloc(strlen(http_hdr->uri) + 1); + if( uri==NULL ) { + mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n"); + return NULL; + } + strcpy(uri,http_hdr->uri); //**** Compute the request length // Add the Method line |