@@ -1338,17 +1338,13 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
break;
}
case MKTAG('g', 'A', 'M', 'A'): {
- AVBPrint bp;
- char *gamma_str;
+ char gamma_str[18];
int num = bytestream2_get_be32(&s->gb);
- av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
- av_bprintf(&bp, "%i/%i", num, 100000);
- ret = av_bprint_finalize(&bp, &gamma_str);
- if (ret < 0)
- return ret;
+ snprintf(gamma_str, sizeof(gamma_str), "%i/100000", num);
- av_dict_set(&p->metadata, "gamma", gamma_str, AV_DICT_DONT_STRDUP_VAL);
+ if ((ret = av_dict_set(&p->metadata, "gamma", gamma_str, 0)) < 0)
+ return ret;
bytestream2_skip(&s->gb, 4); /* crc */
break;
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/pngdec.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)