diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6b4cf2a2465bb84dad3f35d3b8f75fbd8c3fab33..70b059bb8d5e65dd8e52cf3d5fe85b3be93df33d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1204,10 +1204,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
     st = av_new_stream(c->fc, c->fc->nb_streams);
     if (!st) return -2;
     sc = av_mallocz(sizeof(MOVStreamContext));
-    if (!sc) {
-        av_free(st);
-        return -1;
-    }
+    if (!sc) return AVERROR(ENOMEM);
 
     st->priv_data = sc;
     st->codec->codec_type = CODEC_TYPE_DATA;