From 5f49e100dcde71ed1632ee27caa7d9c1a8a0d189 Mon Sep 17 00:00:00 2001 From: in2 Date: Mon, 11 Mar 2002 11:12:05 +0000 Subject: bad memory check for favbuf git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@17 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/board.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mbbsd') 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 #include #include @@ -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); -- cgit v1.2.3