diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-05-22 23:18:09 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-05-22 23:18:09 +0800 |
commit | 774e9e5046fecf6403172494dc59ee535327a757 (patch) | |
tree | e093a3fbe32088a4e4a38f4cc47de3909960a062 | |
parent | be7f3e7ec528ecafd5da15cadf959e69bd239f2b (diff) | |
download | pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar.gz pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar.bz2 pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar.lz pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar.xz pttbbs-774e9e5046fecf6403172494dc59ee535327a757.tar.zst pttbbs-774e9e5046fecf6403172494dc59ee535327a757.zip |
avoid infinite loop
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@186 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/talk.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 6f63350c..31b72ff7 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.36 2002/05/16 21:54:56 in2 Exp $ */ +/* $Id: talk.c,v 1.37 2002/05/22 15:18:09 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <errno.h> @@ -259,13 +259,13 @@ int logout_friend_online(userinfo_t *utmp) int i, j, k; int offset=(int) (utmp - &utmpshm->uinfo[0]); userinfo_t *ui; - while(utmp->friendtotal){ + while( utmp->friendtotal > 0 ){ i = utmp->friendtotal-1; j = (utmp->friend_online[i] & 0xFFFFFF); utmp->friend_online[i]=0; ui = &utmpshm->uinfo[j]; if(ui->pid && ui!=utmp){ - for(k=0; k<ui->friendtotal && k < MAX_FRIEND && + for(k=0; k<ui->friendtotal > 0 && k < MAX_FRIEND && (int)(ui->friend_online[k] & 0xFFFFFF) !=offset; k++); if(k<ui->friendtotal){ ui->friendtotal--; @@ -289,7 +289,7 @@ int friend_stat(userinfo_t *me, userinfo_t * ui) } for(i=0;me->friend_online[i] && i < MAX_FRIEND;i++){ j = (me->friend_online[i] & 0xFFFFFF); - if(ui == &utmpshm->uinfo[j]){ + if( 0 <= j && j < MAX_ACTIVE && ui == &utmpshm->uinfo[j] ){ hit |= me->friend_online[i] >>24; break; } |