[xiph-commits] r13799 - icecast/trunk/avl

karl at svn.xiph.org karl at svn.xiph.org
Thu Sep 13 20:09:32 PDT 2007


Author: karl
Date: 2007-09-13 20:09:32 -0700 (Thu, 13 Sep 2007)
New Revision: 13799

Modified:
   icecast/trunk/avl/avl.c
Log:
add guards for NULL dereference


Modified: icecast/trunk/avl/avl.c
===================================================================
--- icecast/trunk/avl/avl.c	2007-09-14 03:01:17 UTC (rev 13798)
+++ icecast/trunk/avl/avl.c	2007-09-14 03:09:32 UTC (rev 13799)
@@ -822,14 +822,14 @@
     /* search left */
     left = avl_get_prev (node);
     i = m;
-    while ((i > 0) && (tree->compare_fun (tree->compare_arg, key, left->key) == 0)) {
+    while (left && (i > 0) && (tree->compare_fun (tree->compare_arg, key, left->key) == 0)) {
       left = avl_get_prev (left);
       i = i - 1;
     }
     /* search right */
     right = avl_get_next (node);
     j = m;
-    while ((j <= tree->length) && (tree->compare_fun (tree->compare_arg, key, right->key) == 0)) {
+    while (right && (j <= tree->length) && (tree->compare_fun (tree->compare_arg, key, right->key) == 0)) {
       right = avl_get_next (right);
       j = j + 1;
     }
@@ -870,7 +870,7 @@
     avl_node * left;
     /* search left */
     left = avl_get_prev (low_node);
-    while ((i > 0) && (tree->compare_fun (tree->compare_arg, low_key, left->key) == 0)) {
+    while (left && (i > 0) && (tree->compare_fun (tree->compare_arg, low_key, left->key) == 0)) {
       left = avl_get_prev (left);
       i = i - 1;
     }
@@ -881,7 +881,7 @@
     avl_node * right;
     /* search right */
     right = avl_get_next (high_node);
-    while ((j <= tree->length) && (tree->compare_fun (tree->compare_arg, high_key, right->key) == 0)) {
+    while (right && (j <= tree->length) && (tree->compare_fun (tree->compare_arg, high_key, right->key) == 0)) {
       right = avl_get_next (right);
       j = j + 1;
     }



More information about the commits mailing list