]> git.sesse.net Git - ffmpeg/commitdiff
tests/api-flac-test: ensure the frame is writable before writing to it
authorAnton Khirnov <anton@khirnov.net>
Wed, 27 Jan 2021 10:43:03 +0000 (11:43 +0100)
committerAnton Khirnov <anton@khirnov.net>
Mon, 8 Mar 2021 08:29:50 +0000 (09:29 +0100)
The encoder may keep a reference to frames that were sent to it, so the
caller cannot modify them without checking first.

tests/api/api-flac-test.c

index 3fea3258f319bff6756beec9e9e24071f6aca62e..7c96a4d99e8d05f798cea6282f580bedc43a12b7 100644 (file)
@@ -154,6 +154,10 @@ static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx,
         enc_pkt.data = NULL;
         enc_pkt.size = 0;
 
+        result = av_frame_make_writable(in_frame);
+        if (result < 0)
+            return result;
+
         generate_raw_frame((uint16_t*)(in_frame->data[0]), i, enc_ctx->sample_rate,
                            enc_ctx->channels, enc_ctx->frame_size);
         in_frame_bytes = in_frame->nb_samples * in_frame->channels * sizeof(uint16_t);