diff options
| author | david <[email protected]> | 2026-07-23 22:12:42 -0300 |
|---|---|---|
| committer | david <[email protected]> | 2026-07-23 22:12:42 -0300 |
| commit | 17881c653f333baa15f9e7b735466a0333a6cee6 (patch) | |
| tree | 851c25695ca2433714383ecf697e2049e2a6c65e /rat.c | |
| parent | 9765de97f1df3bed997eb341172ba4575f5376f3 (diff) | |
| download | petratc-17881c653f333baa15f9e7b735466a0333a6cee6.tar.gz petratc-17881c653f333baa15f9e7b735466a0333a6cee6.zip | |
fixed a couple bugs
Diffstat (limited to 'rat.c')
| -rw-r--r-- | rat.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -99,9 +99,10 @@ WINDOW *ratdrawbox(void){ } int wrapprint(WINDOW *win, int row, int col, int maxwidth, const char *msg){ + if(msg == NULL) return row; char copy[256]; - strncpy(copy, msg, sizeof(copy)); + strncpy(copy, msg, sizeof(copy) - 1); copy[sizeof(copy)-1] = '\0'; char line[256] = ""; @@ -117,8 +118,14 @@ int wrapprint(WINDOW *win, int row, int col, int maxwidth, const char *msg){ extra = 0; } - if(linelen > 0) strcat(line, " "); - strcat(line, word); + if(linelen > 0) { + if(strlen(line) + 1 < sizeof(line)) { + strcat(line, " "); + } + } + if(strlen(line) + strlen(word) < sizeof(line)) { + strcat(line, word); + } word = strtok(NULL, " "); } |
