Skip to content

Commit

Permalink
Test for string buffer length
Browse files Browse the repository at this point in the history
  • Loading branch information
fnevgeny committed Feb 19, 2023
1 parent 70a3f51 commit 674b51a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/qtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void print_jobs(const job_t *jobs, int njobs, WINDOW *win, int selpos,
int x, __attribute__ ((unused)) y;
getyx(win, y, x);
mvwprintw(win, HEADER_NROWS - 1, x,
"%-*s", COLS - x, dheader + xshift);
"%-*s", COLS - x, xshift < strlen(dheader) ? dheader + xshift : "");

wattroff(win, COLOR_PAIR(COLOR_PAIR_JHEADER) | A_REVERSE);

Expand Down Expand Up @@ -816,7 +816,7 @@ void print_jobs(const job_t *jobs, int njobs, WINDOW *win, int selpos,
}
linebuf[1023] = '\0';

wprintw(win, "%s", linebuf + xshift);
wprintw(win, "%s", xshift < strlen(linebuf) ? linebuf + xshift : "");

getyx(win, y, x);
if (x > 0 && x < COLS) {
Expand Down

0 comments on commit 674b51a

Please sign in to comment.