comparison utils.c @ 32:cd0155c9022e libavformat

zero sized malloc patch by Roman Shaposhnick
author bellard
date Thu, 23 Jan 2003 22:00:57 +0000
parents 90fd30dd68b3
children fb671d87824e
comparison
equal deleted inserted replaced
31:36dd902f98d2 32:cd0155c9022e
384 goto fail1; 384 goto fail1;
385 } 385 }
386 } 386 }
387 387
388 /* allocate private data */ 388 /* allocate private data */
389 ic->priv_data = av_mallocz(fmt->priv_data_size); 389 if (fmt->priv_data_size > 0) {
390 if (!ic->priv_data) { 390 ic->priv_data = av_mallocz(fmt->priv_data_size);
391 err = AVERROR_NOMEM; 391 if (!ic->priv_data) {
392 goto fail; 392 err = AVERROR_NOMEM;
393 } 393 goto fail;
394 }
395 } else
396 ic->priv_data = NULL;
394 397
395 /* default pts settings is MPEG like */ 398 /* default pts settings is MPEG like */
396 av_set_pts_info(ic, 33, 1, 90000); 399 av_set_pts_info(ic, 33, 1, 90000);
397 400
398 err = ic->iformat->read_header(ic, ap); 401 err = ic->iformat->read_header(ic, ap);
720 /* output media file */ 723 /* output media file */
721 724
722 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) 725 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
723 { 726 {
724 int ret; 727 int ret;
725 728
726 s->priv_data = av_mallocz(s->oformat->priv_data_size); 729 if (s->oformat->priv_data_size > 0) {
727 if (!s->priv_data) 730 s->priv_data = av_mallocz(s->oformat->priv_data_size);
728 return AVERROR_NOMEM; 731 if (!s->priv_data)
732 return AVERROR_NOMEM;
733 } else
734 s->priv_data = NULL;
735
729 if (s->oformat->set_parameters) { 736 if (s->oformat->set_parameters) {
730 ret = s->oformat->set_parameters(s, ap); 737 ret = s->oformat->set_parameters(s, ap);
731 if (ret < 0) 738 if (ret < 0)
732 return ret; 739 return ret;
733 } 740 }