summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-11 19:12:05 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-11 19:12:05 +0800
commit5f49e100dcde71ed1632ee27caa7d9c1a8a0d189 (patch)
tree20ac781be056faa6884a74212feeb101f30dec85
parentdc1e907c2cf1038a9dc24a4f4969a8403097bd85 (diff)
downloadpttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar.gz
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar.bz2
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar.lz
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar.xz
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.tar.zst
pttbbs-5f49e100dcde71ed1632ee27caa7d9c1a8a0d189.zip
bad memory check for favbuf
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@17 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/board.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 44b4b842..c8ba647f 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1,4 +1,4 @@
-/* $Id: board.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: board.c,v 1.2 2002/03/11 11:12:05 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -242,7 +242,10 @@ void init_brdbuf() {
n = numboards + 4;
size = n * sizeof(int);
zapbuf = (int *) malloc(size);
- favbuf = (int *) malloc(size);
+ favbuf = (int *) malloc(size + sizeof(int));
+
+ favbuf[0] = 0x5c4d3e; /* for check memory */
+ ++favbuf;
memset(favbuf,0,size);
@@ -275,6 +278,14 @@ void save_brdbuf() {
write(fd, zapbuf, size);
close(fd);
}
+ if( favbuf[-1] != 0x5c4d3e ){
+ time_t now;
+ FILE *fp = fopen(BBSHOME "/log/memorybad", "a");
+ time(&now);
+ fprintf(fp, "%s %s %d\n", cuser.userid, Cdatelite(&now), favbuf[-1]);
+ fclose(fp);
+ return;
+ }
setuserfile(fname, STR_FAV);
if((fd = open(fname, O_WRONLY | O_CREAT, 0600)) != -1) {
size = numboards * sizeof(int);