Always set next correctly, even if a matching element is found (that is
[ffmpeg.git] / libavutil / tree.c
index c929e48..6126ffa 100644 (file)
@@ -35,6 +35,10 @@ void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const v
             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;
         }
     }
@@ -132,7 +136,7 @@ int cmp(const void *a, const void *b){
     return a-b;
 }
 
-int main(){
+int main(void){
     int i,j,k;
     AVTreeNode *root= NULL;