Fix potential race in route table load
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / siwait.c
index 0d1e3e5..128c1a7 100644 (file)
@@ -72,6 +72,7 @@ extern int SIwait( struct ginfo_blk *gptr ) {
        ibuf = (char *) malloc( 2048 );
 
        if( gptr->flags & GIF_SHUTDOWN ) {                              //  cannot do if we should shutdown 
+               free( ibuf );
                return SI_ERROR;                                                        //  so just get out 
        }
 
@@ -93,7 +94,8 @@ extern int SIwait( struct ginfo_blk *gptr ) {
                }
 
                if( pstat > 0  &&  (! (gptr->flags & GIF_SHUTDOWN)) ) {
-                       for( tpptr = gptr->tplist; tpptr != NULL; tpptr = nextone ) {
+                       tpptr = gptr->tplist; 
+                       while( tpptr != NULL ) { 
                                nextone = tpptr->next;                          //  prevent issues if we delete the block during loop 
 
                                if( tpptr->fd >= 0 ) {
@@ -129,6 +131,8 @@ extern int SIwait( struct ginfo_blk *gptr ) {
                                                }
                                        }
                                }                                                               //  if still good fd 
+
+                               tpptr = nextone;
                        }
                }
        } while( gptr->tplist != NULL && !(gptr->flags & GIF_SHUTDOWN) );