Mercurial > hg > nnchat
changeset 535:379e361f1144
Fix various segfault issues.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 14 Aug 2012 02:17:03 +0300 |
parents | b1bb64e2e776 |
children | 15e447d6a2a6 |
files | main.c ui.c |
diffstat | 2 files changed, 16 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Thu Jun 07 03:16:56 2012 +0300 +++ b/main.c Tue Aug 14 02:17:03 2012 +0300 @@ -482,8 +482,8 @@ { if (checkNameList(setFriendList, name)) { - colorNick = 5; - colorText = 1; + colorNick = 11; + colorText = 0; } else { @@ -1506,6 +1506,13 @@ } +void clearEditState(nn_editstate_t *st) +{ + memset(st, 0, sizeof(nn_editstate_t)); + st->insertMode = TRUE; + st->debugMsg = debugMsg; +} + int main(int argc, char *argv[]) { char *tmpStr; @@ -1518,9 +1525,7 @@ char *setHomeDir = NULL; memset(editHistBuf, 0, sizeof(editHistBuf)); - memset(&editState, 0, sizeof(editState)); - editState.insertMode = TRUE; - editState.debugMsg = debugMsg; + clearEditState(&editState); // Initialize th_init("NNChat", "Newbie Nudes chat client", NN_VERSION, @@ -1857,7 +1862,7 @@ { char *tmp; printMsg(NULL, "Press enter to exit.\n"); - memset(&editState, 0, sizeof(editState)); + clearEditState(&editState); tmp = nnwin_prompt_requester(FALSE, &editState, processUserPrompt, updateUserPrompt); th_free(tmp); }
--- a/ui.c Thu Jun 07 03:16:56 2012 +0300 +++ b/ui.c Tue Aug 14 02:17:03 2012 +0300 @@ -403,10 +403,10 @@ " %s | %s | #%06x | WIN: %d: %s / %d | ", tmpStamp, username != NULL ? username : "-", - usercolor, - currWin->num + 1, - currWin->id != NULL ? currWin->id : "MAIN", - currWin->pos); + usercolor, + currWin != NULL ? currWin->num + 1 : 0, + (currWin != NULL && currWin->id != NULL) ? currWin->id : "MAIN", + currWin != NULL ? currWin->pos : 0); #endif wmove(stdscr, scrHeight - 4, 0); @@ -428,7 +428,7 @@ wmove(stdscr, sy, sx); // Update editbuf if needed - if (ebuf != NULL && (force || ebuf->dirty)) + if (cursesInit && ebuf != NULL && (force || ebuf->dirty)) { int yoffs = ebuf->pos / scrWidth, xoffs = ebuf->pos % scrWidth;