[MPlayer-dev-eng] [PATCH] : playlisttree.c : don't use memory after freeing it

jeroen dobbelaere jeroen.dobbelaere at acunia.com
Tue Oct 29 14:33:20 CET 2002


Following patch eliminates the usage of memory after it has been freed in playlisttree.c :
  cvs diff -u playtree.c
Index: playtree.c
===================================================================
RCS file: /cvsroot/mplayer/main/playtree.c,v
retrieving revision 1.14
diff -u -r1.14 playtree.c
--- playtree.c	23 Apr 2002 20:06:00 -0000	1.14
+++ playtree.c	29 Oct 2002 13:33:08 -0000
@@ -32,8 +32,11 @@
  #endif

    if(childs) {
-    for(iter = pt->child; iter != NULL; iter = iter->next)
+    for(iter = pt->child; iter != NULL;) {
+      play_tree_t* nxt=iter->next;
        play_tree_free(iter,1);
+      iter=nxt;
+    }
      pt->child = NULL;
    }

@@ -64,8 +67,11 @@
    for(iter = pt ; iter->prev != NULL ; iter = iter->prev)
      /* NOTHING */;

-  for( ; iter != NULL ; iter = iter->next)
+  for( ; iter != NULL ; ) {
+    play_tree_t* nxt = iter->next;
      play_tree_free(iter,childs);
+    iter = nxt;
+  }


  }


-- 
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com/aes





More information about the MPlayer-dev-eng mailing list