From 7314728d7ce0c7fccd08b18bd113a34ffa66ef15 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 15 Feb 2005 02:56:38 +0000 Subject: fix setperm's bug, check NULL condition first in set_attr git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2512 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/admin.c | 20 +++++++++++--------- mbbsd/fav.c | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/admin.c b/mbbsd/admin.c index da7a79ca..e04999b9 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -236,17 +236,19 @@ setperms(unsigned int pbits, char * const pstring[]) clrtobot(); while ( (i = getkey("½Ð«ö [A-5] ¤Á´«³]©w¡A«ö [Return] µ²§ô¡G"))!='\r') - { - i = i - 'a'; - if (i < 0) - i = i + 'a' - '0' + 26; - if (i >= NUMPERMS) - bell(); + { + if (isdigit(i)) + i = i - '0' + 26; + else if (isalpha(i)) + i = tolower(i) - 'a'; else { - pbits ^= (1 << i); - move(i % 16 + 4, i <= 15 ? 24 : 64); - outs((pbits >> i) & 1 ? "£¾" : "¢æ"); + bell(); + continue; } + + pbits ^= (1 << i); + move(i % 16 + 4, i <= 15 ? 24 : 64); + outs((pbits >> i) & 1 ? "£¾" : "¢æ"); } return pbits; } diff --git a/mbbsd/fav.c b/mbbsd/fav.c index 3a1c1bce..9c534922 100644 --- a/mbbsd/fav.c +++ b/mbbsd/fav.c @@ -182,6 +182,8 @@ inline static int get_line_num(fav_t *fp) { * @param bool: FALSE: unset, TRUE: set, EXCH: opposite */ void set_attr(fav_type_t *ft, int bit, char bool){ + if (ft == NULL) + return; if (bool == EXCH) ft->attr ^= bit; else if (bool == TRUE) -- cgit v1.2.3