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

Fix more Coverity "Issues"

Add some malloc() return checks, comment fall-throughs, and resolve
a sleep while holding lock.

None of these should actually matter, so hopefully I didn't add a
new bug.
parent 78f93473
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4475 passed
......@@ -1270,6 +1270,7 @@ clear2bol(struct cterminal * cterm)
CURR_XY(&x, &y);
buf = malloc(x * sizeof(*buf));
if (buf) {
for(i = 0; i < x; i++) {
if (i > 0)
buf[i] = buf[0];
......@@ -1286,6 +1287,10 @@ clear2bol(struct cterminal * cterm)
vmem_puttext(minx, y, x, y, buf);
free(buf);
}
else {
fprintf(stderr, "malloc() in clear2bol()\n");
}
}
void
cterm_clearscreen(struct cterminal *cterm, char attr)
......@@ -1682,15 +1687,38 @@ static void parse_sixel_string(struct cterminal *cterm, bool finish)
return;
if (cterm->sx_pixels == NULL) {
cterm->sx_pixels = malloc(sizeof(struct ciolib_pixels));
if (cterm->sx_pixels != NULL) {
cterm->sx_pixels->pixels = malloc(sizeof(cterm->sx_pixels->pixels[0]) * cterm->sx_iv * ti.screenwidth * vparams[vmode].charwidth * 6);
if (cterm->sx_pixels->pixels != NULL) {
cterm->sx_pixels->pixelsb = NULL;
cterm->sx_pixels->width = ti.screenwidth * vparams[vmode].charwidth;
cterm->sx_pixels->height = cterm->sx_iv * 6;
cterm->sx_mask = malloc(sizeof(struct ciolib_mask));
if (cterm->sx_mask != NULL) {
cterm->sx_mask->width = cterm->sx_pixels->width;
cterm->sx_mask->height = cterm->sx_pixels->height;
cterm->sx_mask->bits = malloc((cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8);
if (cterm->sx_mask->bits != NULL)
memset(cterm->sx_mask->bits, 0, (cterm->sx_iv * 6 * ti.screenwidth * vparams[vmode].charwidth * 6 + 7)/8);
else {
FREE_AND_NULL(cterm->sx_mask);
free(cterm->sx_pixels->pixels);
FREE_AND_NULL(cterm->sx_pixels);
}
}
else {
free(cterm->sx_pixels->pixels);
FREE_AND_NULL(cterm->sx_pixels);
}
}
else {
FREE_AND_NULL(cterm->sx_pixels);
}
}
}
if (cterm->sx_pixels == NULL) {
fprintf(stderr, "Error allocating memory for sixel data\n");
return;
}
if (cterm->sx_x == cterm->sx_left && cterm->sx_height && cterm->sx_width && cterm->sx_first_pass) {
/* Fill in the background of the line */
......@@ -1879,6 +1907,9 @@ all_done:
setpixels(cterm->sx_x, cterm->sx_y, cterm->sx_x + cterm->sx_width - 1, cterm->sx_y + cterm->sx_height - 1, 0, 0, 0, 0, &px, NULL);
free(px.pixels);
}
else {
fprintf(stderr, "Error allocating memory for sixel data\n");
}
}
if (cterm->extattr & CTERM_EXTATTR_SXSCROLL) {
......
......@@ -708,11 +708,14 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
return;
}
if((sdl_keynext+2==sdl_key) && keyval > 0xff) {
if(keyval==CIO_KEY_MOUSE)
if(keyval==CIO_KEY_MOUSE) {
sdl_pending_mousekeys+=2;
else
beep();
pthread_mutex_unlock(&sdl_keylock);
}
else {
pthread_mutex_unlock(&sdl_keylock);
beep();
}
return;
}
sdl_keybuf[sdl_keynext++]=keyval & 0xff;
......
......@@ -1264,7 +1264,7 @@ local_draw_rect(struct rectlist *rect)
{
int x, y, xoff = 0, yoff = 0;
unsigned int r, g, b;
unsigned long pixel;
unsigned long pixel = 0;
int cleft;
int cright = -100;
int ctop;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment