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
commite6c9ac04e376b9040f9364e26026cd6df2aea176 (patch)
treed60d2a95366d0f4e60d2fdb2b5187222808eb118
parentb2285929d8dca7928f8e4bb771f696408c37b078 (diff)
downloadpttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar.gz
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar.bz2
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar.lz
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar.xz
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.tar.zst
pttbbs-e6c9ac04e376b9040f9364e26026cd6df2aea176.zip
fix memory error
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@488 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/proto.h3
-rw-r--r--pttbbs/mbbsd/cache.c9
-rw-r--r--pttbbs/mbbsd/mbbsd.c3
3 files changed, 10 insertions, 5 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index fe8bad6c..2197427b 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/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/pttbbs/mbbsd/cache.c b/pttbbs/mbbsd/cache.c
index 7c4a1992..ccb8ff33 100644
--- a/pttbbs/mbbsd/cache.c
+++ b/pttbbs/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/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c
index 29121dd9..419c13e9 100644
--- a/pttbbs/mbbsd/mbbsd.c
+++ b/pttbbs/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 */