diff --git a/src/line_info.c b/src/line_info.c index f3e7d60..740a090 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -143,7 +143,7 @@ void line_info_add(ToxWindow *self, char *timestr, char *name1, char *name2, uin if (new_line == NULL) exit_toxic_err("failed in line_info_add", FATALERR_MEMORY); - char frmt_msg[MAX_STR_SIZE] = {0}; + char frmt_msg[MAX_LINE_INFO_MSG_SIZE] = {0}; va_list args; va_start(args, msg); diff --git a/src/line_info.h b/src/line_info.h index 46d2df1..784bdb5 100644 --- a/src/line_info.h +++ b/src/line_info.h @@ -29,6 +29,7 @@ #define MAX_HISTORY 100000 #define MIN_HISTORY 40 #define MAX_LINE_INFO_QUEUE 512 +#define MAX_LINE_INFO_MSG_SIZE MAX_STR_SIZE + TOXIC_MAX_NAME_LENGTH + 32 /* needs extra room for log loading */ enum { SYS_MSG, @@ -47,7 +48,7 @@ struct line_info { char timestr[TIME_STR_SIZE]; char name1[TOXIC_MAX_NAME_LENGTH]; char name2[TOXIC_MAX_NAME_LENGTH]; - char msg[TOX_MAX_MESSAGE_LENGTH]; + char msg[MAX_LINE_INFO_MSG_SIZE]; uint64_t timestamp; uint8_t type; uint8_t bold; diff --git a/src/log.c b/src/log.c index 392114d..238db1f 100644 --- a/src/log.c +++ b/src/log.c @@ -176,7 +176,6 @@ void load_chat_history(ToxWindow *self, struct chatlog *log) ++count; } - char buf[MAX_STR_SIZE]; const char *line = strtok(&hstbuf[start + 1], "\n"); if (line == NULL) { @@ -185,8 +184,7 @@ void load_chat_history(ToxWindow *self, struct chatlog *log) } while (line != NULL) { - snprintf(buf, sizeof(buf), "%s", line); - line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", buf); + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", line); line = strtok(NULL, "\n"); }