chiark / gitweb /
[PATCH] fix SEGV in libsysfs/dlist.c
authorhare@suse.de <hare@suse.de>
Thu, 1 Apr 2004 06:56:45 +0000 (22:56 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:35:13 +0000 (21:35 -0700)
Hi all, Greg,

libsysfs/dlist.c: _dlist_mark_move()

is missing checks for empty lists and may (and indeed, does) crash when=20
called with empty dlists.

libsysfs/dlist.c

index 942eccb..b440d65 100644 (file)
@@ -74,14 +74,14 @@ inline void *_dlist_mark_move(Dlist *list,int direction)
 {
   if(direction)
     {
-      if( list->marker->next!=NULL)
+      if( list->marker && list->marker->next!=NULL)
        list->marker=list->marker->next;
       else
        return(NULL);
     }
   else
     {
-      if( list->marker->prev!=NULL)
+      if( list->marker && list->marker->prev!=NULL)
        list->marker=list->marker->prev;
       else
        return(NULL);