# HG changeset patch # User Matti Hamalainen # Date 1344899823 -10800 # Node ID 379e361f1144e64ec2179c451c5ccb9ae4dacc1a # Parent b1bb64e2e776734fabf6d66852d842d19e4ffc37 Fix various segfault issues. diff -r b1bb64e2e776 -r 379e361f1144 main.c --- 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); } diff -r b1bb64e2e776 -r 379e361f1144 ui.c --- 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;