diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 31e28413e91dadf2f7dde67265a63ad35aa1f2e5..3d4519c1acb06bc20bff31147d841088eb7be24e 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -402,7 +402,7 @@ static int ogg_build_opus_headers(AVCodecContext *avctx,
 static int ogg_write_header(AVFormatContext *s)
 {
     OGGContext *ogg = s->priv_data;
-    OGGStreamContext *oggstream;
+    OGGStreamContext *oggstream = NULL;
     int i, j;
 
     if (ogg->pref_size)