[FFmpeg-devel] [PATCH] Check malloc values in swscale.
Ramiro Polla
ramiro.polla
Sat Aug 15 17:03:32 CEST 2009
On Sat, Aug 15, 2009 at 5:39 AM, Reimar
D?ffinger<Reimar.Doeffinger at gmx.de> wrote:
> On Fri, Aug 14, 2009 at 11:34:12PM -0300, Ramiro Polla wrote:
>> @@ -3331,6 +3390,12 @@ SwsVector *sws_getGaussianVec(double variance, double quality){
>> ? ? ?double middle= (length-1)*0.5;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3350,6 +3415,12 @@ SwsVector *sws_getConstVec(double c, int length){
>> ? ? ?double *coeff= av_malloc(length*sizeof(double));
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3391,6 +3462,12 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b){
>> ? ? ?int i, j;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3413,6 +3490,12 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b){
>> ? ? ?int i;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3430,6 +3513,12 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b){
>> ? ? ?int i;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3448,6 +3537,12 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift){
>> ? ? ?int i;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= length;
>>
>> @@ -3498,6 +3593,12 @@ SwsVector *sws_cloneVec(SwsVector *a){
>> ? ? ?int i;
>> ? ? ?SwsVector *vec= av_malloc(sizeof(SwsVector));
>>
>> + ? ?if (!coeff || !vec) {
>> + ? ? ? ?av_free(coeff);
>> + ? ? ? ?av_free(vec);
>> + ? ? ? ?return NULL;
>> + ? ?}
>> +
>> ? ? ?vec->coeff= coeff;
>> ? ? ?vec->length= a->length;
>
> I think it makes more sense to first reduce the code duplication by fatoring this out into e.g. sws_allocVec
Good idea. Patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sws_allocVec.diff
Type: text/x-diff
Size: 5835 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090815/e906e0bf/attachment.diff>
More information about the ffmpeg-devel
mailing list