summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/admin.c13
-rw-r--r--mbbsd/cal.c3
-rw-r--r--mbbsd/edit.c6
-rw-r--r--mbbsd/friend.c15
-rw-r--r--mbbsd/gamble.c4
-rw-r--r--mbbsd/gomo.c3
-rw-r--r--mbbsd/indict.c3
-rw-r--r--mbbsd/lovepaper.c4
-rw-r--r--mbbsd/mail.c10
-rw-r--r--mbbsd/page.c4
-rw-r--r--mbbsd/syspost.c5
-rw-r--r--mbbsd/user.c8
-rw-r--r--mbbsd/vice.c6
-rw-r--r--mbbsd/vote.c39
-rw-r--r--mbbsd/voteboard.c3
-rw-r--r--mbbsd/xyz.c13
16 files changed, 87 insertions, 52 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 3b41802f..b1d48245 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -1,4 +1,4 @@
-/* $Id: admin.c,v 1.30 2003/01/16 11:58:04 kcwu Exp $ */
+/* $Id: admin.c,v 1.31 2003/01/19 16:06:05 kcwu Exp $ */
#include "bbs.h"
/* 使用者管理 */
@@ -35,6 +35,7 @@ search_key_user(char *passwdfile, int mode)
FILE *fp1 = fopen(passwdfile, "r");
char buf[128], key[22], genbuf[8];
+ assert(fp1);
clear();
getdata(0, 0, mode ? "請輸入使用者關鍵字[電話|地址|姓名|上站地點|"
"email|小雞id] :" : "請輸入id :", key, sizeof(key), DOECHO);
@@ -66,12 +67,15 @@ search_key_user(char *passwdfile, int mode)
while ((ch = igetch()) == 0);
if (ch == ' ')
break;
- if (ch == 'q' || ch == 'Q')
+ if (ch == 'q' || ch == 'Q') {
+ fclose(fp1);
return 0;
+ }
if (ch == 's' && !mode) {
if ((ch = searchuser(user.userid))) {
setumoney(ch, user.money);
passwd_update(ch, &user);
+ fclose(fp1);
return 0;
} else {
move(b_lines - 1, 0);
@@ -98,6 +102,7 @@ search_key_user(char *passwdfile, int mode)
fprintf(stderr, "無法建立帳號\n");
exit(1);
}
+ fclose(fp1);
return 0;
}
}
@@ -1080,8 +1085,10 @@ give_money()
prints("編紅包袋內容");
pressanykey();
- if (vedit("etc/givemoney.why", NA, NULL) < 0)
+ if (vedit("etc/givemoney.why", NA, NULL) < 0) {
+ fclose(fp2);
return 1;
+ }
stand_title("發錢中...");
if (to_all) {
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index d3c00bdd..fe35bd7e 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -1,4 +1,4 @@
-/* $Id: cal.c,v 1.22 2003/01/16 13:51:27 in2 Exp $ */
+/* $Id: cal.c,v 1.23 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
/* 防堵 Multi play */
@@ -182,6 +182,7 @@ osong(char *defaultid)
prints("%s", buf);
pressanykey();
fclose(fp);
+ fclose(fp1);
unlockutmpmode();
return 0;
}
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 354a2abb..f585fab8 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1,4 +1,4 @@
-/* $Id: edit.c,v 1.25 2003/01/16 11:58:04 kcwu Exp $ */
+/* $Id: edit.c,v 1.26 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
typedef struct textline_t {
struct textline_t *prev;
@@ -460,10 +460,11 @@ delete_char()
}
static void
-load_file(FILE * fp)
+load_file(FILE * fp) /* NOTE it will fclose(fp) */
{
int indent_mode0 = indent_mode;
+ assert(fp);
indent_mode = 0;
while (fgets(line, WRAPMARGIN + 2, fp))
insert_string(line);
@@ -972,6 +973,7 @@ write_file(char *fpath, int saveheader, int *islocal)
for (p = firstline; p; p = v) {
v = p->next;
if (!aborted) {
+ assert(fp);
msg = p->data;
if (v || msg[0]) {
trim(msg);
diff --git a/mbbsd/friend.c b/mbbsd/friend.c
index 15a00c50..88cc28f7 100644
--- a/mbbsd/friend.c
+++ b/mbbsd/friend.c
@@ -1,4 +1,4 @@
-/* $Id: friend.c,v 1.14 2002/12/31 17:40:51 in2 Exp $ */
+/* $Id: friend.c,v 1.15 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
/* ------------------------------------- */
@@ -118,11 +118,13 @@ friend_special()
special_des[5] = i + '0';
setuserfile(fname, special_des);
if (dashf(fname)) {
- /* no NULL check?? */
+ /* XXX no NULL check?? */
FILE *fp = fopen(fname, "r");
+ assert(fp);
fgets(genbuf + 15, 40, fp);
genbuf[47] = 0;
+ fclose(fp);
}
move(i + 12, 0);
clrtoeol();
@@ -212,7 +214,7 @@ friend_delete(char *uident, int type)
setfriendfile(fn, type);
sprintf(fnnew, "%s-", fn);
- if ((fp = fopen(fn, "r")) && (nfp = fopen(fnnew, "w"))) {
+ if ((fp = fopen(fn, "r")) && (nfp = fopen(fnnew, "w"))) { // XXX fclose(fp) if nfp fail
int length = strlen(uident);
while (fgets(genbuf, STRLEN, fp))
@@ -231,7 +233,7 @@ friend_editdesc(char *uident, int type)
char fnnew[200], genbuf[200], fn[200];
setfriendfile(fn, type);
snprintf(fnnew, sizeof(fnnew), "%s-", fn);
- if ((fp = fopen(fn, "r")) && (nfp = fopen(fnnew, "w"))) {
+ if ((fp = fopen(fn, "r")) && (nfp = fopen(fnnew, "w"))) { // XXX fclose(fp) if nfp fail
int length = strlen(uident);
while (fgets(genbuf, STRLEN, fp)) {
@@ -297,7 +299,7 @@ friend_water(char *message, int type)
FILE *fp;
setfriendfile(fpath, type);
- if ((fp = fopen(fpath, "r")))
+ if ((fp = fopen(fpath, "r"))) {
while (fgets(line, 80, fp)) {
userinfo_t *uentp;
int tuid;
@@ -308,7 +310,8 @@ friend_water(char *message, int type)
isvisible_uid(tuid))
my_write(uentp->pid, message, uentp->userid, 1, NULL);
}
- fclose(fp);
+ fclose(fp);
+ }
}
void
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index d9b3ea2b..b1643fb5 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -1,4 +1,4 @@
-/* $Id: gamble.c,v 1.31 2003/01/16 14:14:12 kcwu Exp $ */
+/* $Id: gamble.c,v 1.32 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#ifndef _BBS_UTIL_C_
@@ -273,7 +273,7 @@ openticket(int bid)
} else
fprintf(fp, "\n\n賭盤取消退錢: %s \n\n", Cdatelite(&now));
- }
+ } // XXX somebody may use fp even fp==NULL
fclose(fp1);
setbfile(buf, bh->brdname, FN_TICKET_END);
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index b7665bae..3a8fcd5f 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -1,4 +1,4 @@
-/* $Id: gomo.c,v 1.11 2003/01/16 14:14:12 kcwu Exp $ */
+/* $Id: gomo.c,v 1.12 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
static char *chess[] = {"●", "○"};
@@ -56,6 +56,7 @@ HO_log(Horder_t *pool, char *user)
snprintf(buf, sizeof(buf), "home/%c/%s/F.%d",
cuser.userid[0], cuser.userid, rand() & 65535);
log = fopen(buf, "w");
+ assert(log);
for (i = 1; i < 17; i++)
fprintf(log, "%.*s\n", big_picture[i].len, big_picture[i].data);
diff --git a/mbbsd/indict.c b/mbbsd/indict.c
index 93d955a1..1de9b02c 100644
--- a/mbbsd/indict.c
+++ b/mbbsd/indict.c
@@ -1,4 +1,4 @@
-/* $Id: indict.c,v 1.11 2003/01/16 14:37:31 kcwu Exp $ */
+/* $Id: indict.c,v 1.12 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#define REFER "etc/dicts"
@@ -51,6 +51,7 @@ choose_dict(void)
"(\033[36m%d\033[m) %-20s大字典", c + 1, buf[c]);
outs(cho);
}
+ fclose(fp);
getdata(22, 14, " ★ 請選擇,[Enter]離開:", cho, 3, LCECHO);
cho[0] -= '1';
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 47370524..1ab87944 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -1,4 +1,4 @@
-/* $Id: lovepaper.c,v 1.10 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id: lovepaper.c,v 1.11 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#define DATA "etc/lovepaper.dat"
@@ -34,6 +34,7 @@ x_love()
return 0;
}
fpo = fopen(path, "w");
+ assert(fpo);
fprintf(fpo, "\n");
if ((fp = fopen(DATA, "r"))) {
while (fgets(buf1, 100, fp)) {
@@ -102,5 +103,6 @@ x_love()
hold_mail(buf1, receiver);
return 1;
}
+ fclose(fpo);
return 0;
}
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 7f145867..3d06e087 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1,4 +1,4 @@
-/* $Id: mail.c,v 1.24 2003/01/16 14:47:43 kcwu Exp $ */
+/* $Id: mail.c,v 1.25 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
char currmaildir[32];
static char msg_cc[] = "\033[32m[群組名單]\033[m\n";
@@ -434,6 +434,7 @@ multi_send(char *title)
AddNameList(quote_user);
reciper = 1;
fp = fopen(quote_file, "r");
+ assert(fp);
while (fgets(genbuf, 256, fp)) {
if (strncmp(genbuf, "※ ", 3)) {
if (listing)
@@ -452,6 +453,7 @@ multi_send(char *title)
listing = 1;
}
}
+ fclose(fp);
ShowNameList(3, 0, msg_cc);
}
multi_list(&reciper);
@@ -995,7 +997,7 @@ mail_reply(int ent, fileheader_t * fhdr, char *direct)
if (strchr(quote_user, '.')) {
genbuf[0] = '\0';
if ((fp = fopen(quote_file, "r"))) {
- fgets(genbuf, 512, fp);
+ fgets(genbuf, sizeof(genbuf), fp);
fclose(fp);
}
t = strtok(genbuf, str_space);
@@ -1167,6 +1169,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
setuserfile(fname, fhdr->filename);
if (ent) {
xptr = fopen(xfpath, "w");
+ assert(xptr);
strlcpy(save_title, xfile.title, sizeof(save_title));
strlcpy(xfpath, currboard, sizeof(xfpath));
@@ -1349,6 +1352,7 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct)
snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.des.%s-%d",
cuser.userid, (int)now);
fp = fopen(fname, "wt");
+ assert(fp);
fprintf(fp, "%s\n%s\n%d\n", cuser.userid, address, cmode);
fclose(fp);
vmsg("設定完成, 系統將在下一個整點(尖鋒時段除外)將資料寄給您");
@@ -1458,7 +1462,7 @@ bbs_sendmail(char *fpath, char *title, char *receiver)
fin = fopen(fpath, "r");
}
fout = popen(genbuf, "w");
- if (fin == NULL || fout == NULL)
+ if (fin == NULL || fout == NULL) // XXX no fclose() if only one fopen succeed
return -1;
if (fpath)
diff --git a/mbbsd/page.c b/mbbsd/page.c
index e32b73f2..9c01eb6d 100644
--- a/mbbsd/page.c
+++ b/mbbsd/page.c
@@ -1,4 +1,4 @@
-/* $Id: page.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id: page.c,v 1.10 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#define hpressanykey(a) {move(22, 0); prints(a); pressanykey();}
@@ -9,7 +9,7 @@ filt_railway(char *fpath)
FILE *fp = fopen(fpath, "w"), *tp;
snprintf(tmppath, sizeof(tmppath), "%s.railway", fpath);
- if (!fp || !(tp = fopen(tmppath, "r")))
+ if (!fp || !(tp = fopen(tmppath, "r"))) // XXX fclose(fp) if tp fail
return;
while (fgets(buf, 255, tp)) {
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c
index a44ffdb3..8fdc361c 100644
--- a/mbbsd/syspost.c
+++ b/mbbsd/syspost.c
@@ -1,4 +1,4 @@
-/* $Id: syspost.c,v 1.17 2003/01/16 13:28:48 kcwu Exp $ */
+/* $Id: syspost.c,v 1.18 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
int
@@ -94,7 +94,8 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid)
cuser.userid, userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
- }
+ } else
+ fclose(fp);
}
void
diff --git a/mbbsd/user.c b/mbbsd/user.c
index e3bb1f89..c236279a 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1,4 +1,4 @@
-/* $Id: user.c,v 1.44 2002/12/31 17:40:52 in2 Exp $ */
+/* $Id: user.c,v 1.45 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
static char *sex[8] = {
@@ -568,6 +568,7 @@ u_switchproverb()
setuserfile(buf, fn_proverb);
if (cuser.proverb == 2 && dashd(buf)) {
FILE *fp = fopen(buf, "a");
+ assert(fp);
fprintf(fp, "座右銘狀態為[自定型]要記得設座右銘的內容唷!!");
fclose(fp);
@@ -620,7 +621,9 @@ showsignature(char *fname)
fname[j] = ch;
if ((fp = fopen(fname, "r"))) {
prints("\033[36m【 簽名檔.%c 】\033[m\n", ch);
- for (i = 0; i++ < MAX_SIGLINES && fgets(buf, 256, fp); outs(buf));
+ for (i = 0; i < MAX_SIGLINES && fgets(buf, sizeof(buf), fp); i++)
+ outs(buf);
+
fclose(fp);
}
}
@@ -826,6 +829,7 @@ toregister(char *email, char *genbuf, char *phone, char *career,
sethomefile(buf, cuser.userid, "justify.wait");
if (phone[0] != 0) {
fn = fopen(buf, "w");
+ assert(fn);
fprintf(fn, "%s\n%s\n%s\n%s\n%s\n%s\n",
phone, career, ident, rname, addr, mobile);
fclose(fn);
diff --git a/mbbsd/vice.c b/mbbsd/vice.c
index acc653fa..2f5aa310 100644
--- a/mbbsd/vice.c
+++ b/mbbsd/vice.c
@@ -1,4 +1,4 @@
-/* $Id: vice.c,v 1.6 2002/07/22 19:02:01 in2 Exp $ */
+/* $Id: vice.c,v 1.7 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#define VICE_PLAY BBSHOME "/etc/vice/vice.play"
@@ -22,7 +22,7 @@ vice_load(char tbingo[6][15])
int i = 0;
if (!fb)
return -1;
- bzero((char *)tbingo, sizeof(tbingo));
+ bzero((char *)tbingo, 6*15);
while (i < 6 && fgets(buf, 15, fb)) {
if ((ptr = strchr(buf, '\n')))
*ptr = 0;
@@ -53,7 +53,7 @@ ran_showfile(int y, int x, char *filename, int maxnum)
FILE *fs;
char buf[512];
- bzero(buf, sizeof(char) * 512);
+ bzero(buf, sizeof(buf));
snprintf(buf, sizeof(buf), "%s%d", filename, rand() % maxnum + 1);
if (!(fs = fopen(buf, "r"))) {
move(10, 10);
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index 70313920..618da18a 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -1,4 +1,4 @@
-/* $Id: vote.c,v 1.17 2003/01/16 11:58:05 kcwu Exp $ */
+/* $Id: vote.c,v 1.18 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
static int total;
@@ -224,6 +224,7 @@ b_result_one(boardheader_t * fh, int ind)
if ((xfp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), xfp);
fprintf(tfp, "%s\n◆ 投票名稱: %s\n\n", msg_seperator, inbuf);
+ fclose(xfp);
}
fprintf(tfp, "%s\n◆ 投票中止於: %s\n\n◆ 票選題目描述:\n\n",
msg_seperator, ctime(&closetime));
@@ -399,6 +400,7 @@ vote_view(char *bname, int index)
if ((fp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), fp);
prints("\n投票名稱: %s", inbuf);
+ fclose(fp);
}
setbfile(buf, bname, STR_new_control);
fp = fopen(buf, "r");
@@ -486,12 +488,12 @@ vote_view_all(char *bname)
fclose(fp);
setbfile(buf, bname, STR_new_title);
- if ((xfp = fopen(buf, "r")))
+ if ((xfp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), xfp);
- else
+ fclose(xfp);
+ } else
strlcpy(inbuf, "無標題", sizeof(inbuf));
prints("%s\n", inbuf);
- fclose(xfp);
}
for (i = 1; i < 20; i++) {
snprintf(STR_new_control, sizeof(STR_new_control),
@@ -505,12 +507,12 @@ vote_view_all(char *bname)
fclose(fp);
setbfile(buf, bname, STR_new_title);
- if ((xfp = fopen(buf, "r")))
+ if ((xfp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), xfp);
- else
+ fclose(xfp);
+ } else
strlcpy(inbuf, "無標題", sizeof(inbuf));
prints("%s\n", inbuf);
- fclose(xfp);
}
}
@@ -531,7 +533,7 @@ vote_view_all(char *bname)
setbfile(buf, bname, STR_new_control);
- if ((fp = fopen(buf, "r"))) {
+ if ((fp = fopen(buf, "r"))) { // TODO try access()
fclose(fp);
return vote_view(bname, atoi(genbuf));
} else
@@ -618,15 +620,13 @@ vote_maintain(char *bname)
strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control));
setbfile(buf, bname, STR_new_control);
x = 0;
- while (x < 20 && (fp = fopen(buf, "r")) != NULL) {
+ while (x < 20 && (fp = fopen(buf, "r")) != NULL) { // TODO try access()
fclose(fp);
x++;
snprintf(STR_new_control, sizeof(STR_new_control),
"%s%d", STR_bv_control, x);
setbfile(buf, bname, STR_new_control);
}
- if (fp)
- fclose(fp);
if (x >= 20)
return FULLUPDATE;
if (x) {
@@ -654,6 +654,7 @@ vote_maintain(char *bname)
if (inbuf[0] == '\0')
strlcpy(inbuf, "不知名的", sizeof(inbuf));
fp = fopen(buf, "w");
+ assert(fp);
fprintf(fp, "%s", inbuf);
fclose(fp);
@@ -677,6 +678,7 @@ vote_maintain(char *bname)
setbfile(buf, bname, STR_new_limited);
if (inbuf[0] == 'y') {
fp = fopen(buf, "w");
+ assert(fp);
fprintf(fp, "此次投票設限");
fclose(fp);
friend_edit(FRIEND_CANVOTE);
@@ -696,6 +698,7 @@ vote_maintain(char *bname)
closetime = closetime * 86400 + now;
setbfile(buf, bname, STR_new_control);
fp = fopen(buf, "w");
+ assert(fp);
fprintf(fp, "00\n%lu\n", closetime);
outs("\n請依序輸入選項, 按 ENTER 完成設定");
@@ -994,12 +997,12 @@ user_vote(char *bname)
fclose(fp);
setbfile(buf, bname, STR_new_title);
- if ((xfp = fopen(buf, "r")))
+ if ((xfp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), xfp);
- else
+ fclose(xfp);
+ } else
strlcpy(inbuf, "無標題", sizeof(inbuf));
prints("%s\n", inbuf);
- fclose(xfp);
}
for (i = 1; i < 20; i++) {
snprintf(STR_new_control, sizeof(STR_new_control),
@@ -1013,12 +1016,12 @@ user_vote(char *bname)
fclose(fp);
setbfile(buf, bname, STR_new_title);
- if ((xfp = fopen(buf, "r")))
+ if ((xfp = fopen(buf, "r"))) {
fgets(inbuf, sizeof(inbuf), xfp);
- else
+ fclose(xfp);
+ } else
strlcpy(inbuf, "無標題", sizeof(inbuf));
prints("%s\n", inbuf);
- fclose(xfp);
}
}
@@ -1040,7 +1043,7 @@ user_vote(char *bname)
setbfile(buf, bname, STR_new_control);
- if ((fp = fopen(buf, "r"))) {
+ if ((fp = fopen(buf, "r"))) { // TODO try access()
fclose(fp);
return user_vote_one(bname, atoi(genbuf));
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index 76bf0cbc..d1696547 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -1,4 +1,4 @@
-/* $Id: voteboard.c,v 1.14 2002/08/20 02:42:36 in2 Exp $ */
+/* $Id: voteboard.c,v 1.15 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
#define VOTEBOARD "NewBoard"
@@ -37,6 +37,7 @@ do_voteboardreply(fileheader_t * fhdr)
strcat(oldfpath, fhdr->filename);
fp = fopen(oldfpath, "r");
+ assert(fp);
len = strlen(cuser.userid);
diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c
index 707ae02e..948a4275 100644
--- a/mbbsd/xyz.c
+++ b/mbbsd/xyz.c
@@ -1,4 +1,4 @@
-/* $Id: xyz.c,v 1.14 2003/01/16 20:22:06 kcwu Exp $ */
+/* $Id: xyz.c,v 1.15 2003/01/19 16:06:06 kcwu Exp $ */
#include "bbs.h"
/* 各種統計及相關資訊列表 */
@@ -211,11 +211,16 @@ note()
if ((foo = fopen(".note", "a")) == NULL)
return 0;
- if ((fp = fopen(fn_note_ans, "w")) == NULL)
+ if ((fp = fopen(fn_note_ans, "w")) == NULL) {
+ fclose(fp);
return 0;
+ }
- if ((fx = open(fn_note_tmp, O_WRONLY | O_CREAT, 0644)) <= 0)
+ if ((fx = open(fn_note_tmp, O_WRONLY | O_CREAT, 0644)) <= 0) {
+ fclose(foo);
+ fclose(fp);
return 0;
+ }
if ((fd = open(fn_note_dat, O_RDONLY)) == -1)
total = 1;
@@ -305,6 +310,7 @@ mail_sysop()
}
}
}
+ fclose(fp);
move(12, 0);
clrtobot();
@@ -463,7 +469,6 @@ x_archie()
if (*ans == 'y') {
fileheader_t mhdr;
char title[128], buf1[80];
- FILE *fp;
sethomepath(buf1, cuser.userid);
stampfile(buf1, &mhdr);