diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c
index 8333050bab44d799ba5e88586d5b86a32c67bbbe..da136991645c9f877c12b86444ada6072b99f443 100644
--- a/libavcodec/ffjni.c
+++ b/libavcodec/ffjni.c
@@ -227,7 +227,7 @@ int ff_jni_exception_get_summary(JNIEnv *env, jthrowable exception, char **error
     jclass exception_class = NULL;
     jmethodID get_message_id = NULL;
 
-    jstring string;
+    jstring string = NULL;
 
     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);