Skip to content
Snippets Groups Projects
Commit 252e539c authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

"Handle" malloc() failures

Just scream on stderr, and screw things up in the window.
parent 0dc37aae
No related branches found
No related tags found
No related merge requests found
Pipeline #7024 passed
...@@ -994,6 +994,10 @@ prestel_get_state(struct cterminal *cterm) ...@@ -994,6 +994,10 @@ prestel_get_state(struct cterminal *cterm)
SCR_XY(&sx, &sy); SCR_XY(&sx, &sy);
TERM_XY(&tx, &ty); TERM_XY(&tx, &ty);
line = malloc(sizeof(*line) * tx); line = malloc(sizeof(*line) * tx);
if (line == NULL) {
fprintf(stderr, "malloc() in prestel_get_state()\n");
return;
}
prestel_new_line(cterm); prestel_new_line(cterm);
if (tx > 1) { if (tx > 1) {
vmem_gettext(cterm->x, sy, cterm->x + tx - 2, sy, line); vmem_gettext(cterm->x, sy, cterm->x + tx - 2, sy, line);
...@@ -4982,6 +4986,10 @@ static void prestel_fix_line(struct cterminal *cterm, int x, int y, bool restore ...@@ -4982,6 +4986,10 @@ static void prestel_fix_line(struct cterminal *cterm, int x, int y, bool restore
coord_conv_xy(cterm, CTERM_COORD_TERM, CTERM_COORD_SCREEN, &sy, &sx); coord_conv_xy(cterm, CTERM_COORD_TERM, CTERM_COORD_SCREEN, &sy, &sx);
ex = sx + TERM_MAXX - 1; ex = sx + TERM_MAXX - 1;
line = malloc(sizeof(*line) * (ex - sx + 1)); line = malloc(sizeof(*line) * (ex - sx + 1));
if (line == NULL) {
fprintf(stderr, "malloc() in prestel_get_state()\n");
return;
}
vmem_gettext(sx, sy, ex, sy, line); vmem_gettext(sx, sy, ex, sy, line);
prestel_new_line(cterm); prestel_new_line(cterm);
for (int i = 0; i < TERM_MAXX; i++) { for (int i = 0; i < TERM_MAXX; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment