summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-24 02:01:30 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-24 02:01:30 +0800
commit7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3 (patch)
treeea6aae1cc1f439df2009894cea12408a93a5a2a3
parentbc71e83b569d1297713d0cb77c2d5c2e6a59e587 (diff)
downloadpttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar.gz
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar.bz2
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar.lz
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar.xz
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.tar.zst
pttbbs-7215f7de56c3d26487fcfe1a4e9b04c3d2b309a3.zip
fix memory error
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@488 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h3
-rw-r--r--mbbsd/cache.c9
-rw-r--r--mbbsd/mbbsd.c3
3 files changed, 10 insertions, 5 deletions
diff --git a/include/proto.h b/include/proto.h
index fe8bad6c..2197427b 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.27 2002/08/20 02:42:36 in2 Exp $ */
+/* $Id: proto.h,v 1.28 2002/08/23 18:01:28 in2 Exp $ */
#ifndef INCLUDE_PROTO_H
#define INCLUDE_PROTO_H
@@ -117,6 +117,7 @@ int get_fileheader_cache(int bid, char *direct, fileheader_t *headers,
int recbase, int nlines);
void *attach_shm(int shmkey, int shmsize);
void attach_SHM(void);
+void sort_utmp();
/* cal */
int give_tax(int money);
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 7c4a1992..ccb8ff33 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.49 2002/08/20 02:42:36 in2 Exp $ */
+/* $Id: cache.c,v 1.50 2002/08/23 18:01:30 in2 Exp $ */
#include "bbs.h"
#ifndef __FreeBSD__
@@ -527,8 +527,11 @@ search_ulistn(int uid, int unum)
for (i = ((start + end) / 2);; i = (start + end) / 2) {
j = uid - ulist[i]->uid;
if (j == 0) {
- for (; i > 0 && uid == ulist[i - 1]->uid; --i); /* 指到第一筆 */
- if (ulist[i + unum - 1] != NULL && uid == ulist[i + unum - 1]->uid)
+ for (; i > 0 && uid == ulist[i - 1]->uid; --i)
+ ;/* 指到第一筆 */
+ if ( i + unum - 1 >= 0 &&
+ (ulist[i + unum - 1] != NULL &&
+ uid == ulist[i + unum - 1]->uid) )
return (userinfo_t *) (ulist[i + unum - 1]);
break; /* 超過範圍 */
}
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 29121dd9..419c13e9 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1,4 +1,4 @@
-/* $Id: mbbsd.c,v 1.49 2002/08/23 11:33:01 in2 Exp $ */
+/* $Id: mbbsd.c,v 1.50 2002/08/23 18:01:30 in2 Exp $ */
#include "bbs.h"
#define SOCKET_QLEN 4
@@ -448,6 +448,7 @@ multi_user_check()
return; /* don't check sysops */
if (cuser.userlevel) {
+ sort_utmp();
if (!(ui = (userinfo_t *) search_ulist(usernum)))
return; /* user isn't logged in */