diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index dbbaab64661d8c649f23e1ba0ebcae4066f2f7ea..3581431c2537f163610be5d65a275401d1193eec 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -147,9 +147,9 @@ static int get_http_header_data(MMSHContext *mmsh)
 
     for (;;) {
         len = 0;
-        chunk_type = get_chunk_header(mmsh, &len);
-        if (chunk_type < 0) {
-            return chunk_type;
+        res = chunk_type = get_chunk_header(mmsh, &len);
+        if (res < 0) {
+            return res;
         } else if (chunk_type == CHUNK_TYPE_ASF_HEADER){
             // get asf header and stored it
             if (!mms->header_parsed) {