avio: Check for memory allocation failure of private data
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
parent
52aed19307
commit
d206fd996b
@ -143,6 +143,10 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
|
|||||||
uc->max_packet_size = 0; /* default: stream file */
|
uc->max_packet_size = 0; /* default: stream file */
|
||||||
if (up->priv_data_size) {
|
if (up->priv_data_size) {
|
||||||
uc->priv_data = av_mallocz(up->priv_data_size);
|
uc->priv_data = av_mallocz(up->priv_data_size);
|
||||||
|
if (!uc->priv_data) {
|
||||||
|
err = AVERROR(ENOMEM);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
if (up->priv_data_class) {
|
if (up->priv_data_class) {
|
||||||
int proto_len= strlen(up->name);
|
int proto_len= strlen(up->name);
|
||||||
char *start = strchr(uc->filename, ',');
|
char *start = strchr(uc->filename, ',');
|
||||||
@ -180,6 +184,9 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
|
|||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
*puc = NULL;
|
*puc = NULL;
|
||||||
|
if (uc)
|
||||||
|
av_freep(&uc->priv_data);
|
||||||
|
av_freep(&uc);
|
||||||
#if CONFIG_NETWORK
|
#if CONFIG_NETWORK
|
||||||
if (up->flags & URL_PROTOCOL_FLAG_NETWORK)
|
if (up->flags & URL_PROTOCOL_FLAG_NETWORK)
|
||||||
ff_network_close();
|
ff_network_close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user