From fb0f9fb4276c7183f04046d82d124fe0eabfd460 Mon Sep 17 00:00:00 2001 From: piaip Date: Wed, 21 Sep 2005 05:41:18 +0000 Subject: reduce mywrite segv (hope so) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3198 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/talk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 56f1d4bd..503eac7a 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -674,6 +674,10 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p uin = (puin != NULL) ? puin : (userinfo_t *) search_ulist_pid(pid); strlcpy(destid, id, sizeof(destid)); + /* what if uin is NULL but other conditions are not true? + * will this situation cause SEGV? + * should this "!uin &&" replaced by "!uin ||" ? + */ if (!uin && !((flag == WATERBALL_GENERAL #ifdef PLAY_ANGEL || flag == WATERBALL_ANGEL || flag == WATERBALL_ANSWER @@ -706,10 +710,14 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p move(1, 0); clrtoeol(); outs(ANSI_COLOR(1;31) "你的呼叫器目前不接受別人丟水球,對方可能無法回話。" ANSI_RESET); break; + case PAGER_FRIENDONLY: - fri_stat = friend_stat(currutmp, uin); - if(fri_stat & HFM) - break; + if (uin) + { + fri_stat = friend_stat(currutmp, uin); + if(fri_stat & HFM) + break; + } move(1, 0); clrtoeol(); outs(ANSI_COLOR(1;31) "你的呼叫器目前只接受好友丟水球,對方可能無法回話。" ANSI_RESET); break; -- cgit v1.2.3