diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 2e5e641c7bfdf8905c8dcd8dc3b5a9021d344f79..97c8ad61bc9739f9db8cb4e87d44136d8929705d 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -189,6 +189,8 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
 
             if (sep)
                 p = sep + 1;
+            else
+                break;
         }
     }
     if (ctx->playpath) {