summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-04-14 13:37:38 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-04-14 13:37:38 +0000
commit5c51b1378541b894d0a1efeda54a29c25ae51e71 (patch)
tree37a88d246d361c241fbfe86c6c522f8e0f7becb6 /libmpdemux
parentecc88de7f626da41b1c56979b2382a2bd7d2a7ff (diff)
downloadmpv-5c51b1378541b894d0a1efeda54a29c25ae51e71.tar.bz2
mpv-5c51b1378541b894d0a1efeda54a29c25ae51e71.tar.xz
free memory on error in http_add_basic_authentication
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18095 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/http.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libmpdemux/http.c b/libmpdemux/http.c
index f5eb844312..95ad075333 100644
--- a/libmpdemux/http.c
+++ b/libmpdemux/http.c
@@ -585,8 +585,9 @@ http_set_uri( HTTP_header_t *http_hdr, const char *uri ) {
int
http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, const char *password ) {
- char *auth, *usr_pass, *b64_usr_pass;
+ char *auth = NULL, *usr_pass = NULL, *b64_usr_pass = NULL;
int encoded_len, pass_len=0, out_len;
+ int res = -1;
if( http_hdr==NULL || username==NULL ) return -1;
if( password!=NULL ) {
@@ -596,7 +597,7 @@ http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, co
usr_pass = (char*)malloc(strlen(username)+pass_len+2);
if( usr_pass==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
- return -1;
+ goto out;
}
sprintf( usr_pass, "%s:%s", username, (password==NULL)?"":password );
@@ -606,13 +607,13 @@ http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, co
b64_usr_pass = (char*)malloc(encoded_len);
if( b64_usr_pass==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
- return -1;
+ goto out;
}
out_len = base64_encode( usr_pass, strlen(usr_pass), b64_usr_pass, encoded_len);
if( out_len<0 ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,"Base64 out overflow\n");
- return -1;
+ goto out;
}
b64_usr_pass[out_len]='\0';
@@ -620,17 +621,19 @@ http_add_basic_authentication( HTTP_header_t *http_hdr, const char *username, co
auth = (char*)malloc(encoded_len+22);
if( auth==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
- return -1;
+ goto out;
}
sprintf( auth, "Authorization: Basic %s", b64_usr_pass);
http_set_field( http_hdr, auth );
+ res = 0;
+out:
free( usr_pass );
free( b64_usr_pass );
free( auth );
- return 0;
+ return res;
}
void