Always set next correctly, even if a matching element is found (that is
how it is documented and used).

Originally committed as revision 11391 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavutil/tree.c b/libavutil/tree.c
index f4b9af1..6126ffa 100644
--- a/libavutil/tree.c
+++ b/libavutil/tree.c
@@ -35,6 +35,10 @@
             if(next) next[(v>>31)^1]= t->elem;
             return av_tree_find(t->child[v>>31], key, cmp, next);
         }else{
+            if(next){
+                av_tree_find(t->child[0], key, cmp, next);
+                av_tree_find(t->child[1], key, cmp, next);
+            }
             return t->elem;
         }
     }