comparison libmpdemux/network.c @ 16417:be6bbd50ec20

memleak fixes when invalid http url specified.
author reimar
date Tue, 06 Sep 2005 21:00:57 +0000
parents 4ee24ec6ac16
children 0d860b6d64e6
comparison
equal deleted inserted replaced
16416:42ad241f6e8c 16417:be6bbd50ec20
415 if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url ); 415 if (network_cookies_enabled) cookies_set( http_hdr, server_url->hostname, server_url->url );
416 416
417 http_set_field( http_hdr, "Connection: close"); 417 http_set_field( http_hdr, "Connection: close");
418 http_add_basic_authentication( http_hdr, url->username, url->password ); 418 http_add_basic_authentication( http_hdr, url->username, url->password );
419 if( http_build_request( http_hdr )==NULL ) { 419 if( http_build_request( http_hdr )==NULL ) {
420 return -1; 420 goto err_out;
421 } 421 }
422 422
423 if( proxy ) { 423 if( proxy ) {
424 if( url->port==0 ) url->port = 8080; // Default port for the proxy server 424 if( url->port==0 ) url->port = 8080; // Default port for the proxy server
425 fd = connect2Server( url->hostname, url->port,1 ); 425 fd = connect2Server( url->hostname, url->port,1 );
427 } else { 427 } else {
428 if( server_url->port==0 ) server_url->port = 80; // Default port for the web server 428 if( server_url->port==0 ) server_url->port = 80; // Default port for the web server
429 fd = connect2Server( server_url->hostname, server_url->port,1 ); 429 fd = connect2Server( server_url->hostname, server_url->port,1 );
430 } 430 }
431 if( fd<0 ) { 431 if( fd<0 ) {
432 return -1; 432 goto err_out;
433 } 433 }
434 mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request: [%s]\n", http_hdr->buffer ); 434 mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request: [%s]\n", http_hdr->buffer );
435 435
436 ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 ); 436 ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 );
437 if( ret!=(int)http_hdr->buffer_size ) { 437 if( ret!=(int)http_hdr->buffer_size ) {
438 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: didn't sent all the request\n"); 438 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: didn't sent all the request\n");
439 return -1; 439 goto err_out;
440 } 440 }
441 441
442 http_free( http_hdr ); 442 http_free( http_hdr );
443 443
444 return fd; 444 return fd;
445 err_out:
446 http_free(http_hdr);
447 return -1;
445 } 448 }
446 449
447 HTTP_header_t * 450 HTTP_header_t *
448 http_read_response( int fd ) { 451 http_read_response( int fd ) {
449 HTTP_header_t *http_hdr; 452 HTTP_header_t *http_hdr;