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

Snoop through Coverity issues and fix the easy/important ones

parent 2d3f4e18
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4435 passed
......@@ -461,6 +461,7 @@ static struct rectlist *alloc_full_rect(struct bitmap_screen *screen, bool allow
pthread_mutex_unlock(&free_rect_lock);
ret = malloc(sizeof(struct rectlist));
if (ret) {
ret->next = NULL;
ret->throttle = allow_throttle;
ret->rect.x = 0;
......@@ -470,6 +471,7 @@ static struct rectlist *alloc_full_rect(struct bitmap_screen *screen, bool allow
ret->data = malloc(ret->rect.width * ret->rect.height * sizeof(ret->data[0]));
if (ret->data == NULL)
FREE_AND_NULL(ret);
}
pthread_mutex_lock(&free_rect_lock);
if (allow_throttle) {
if (ret)
......
......@@ -1869,6 +1869,7 @@ all_done:
struct ciolib_pixels px;
px.pixels = malloc(sizeof(px.pixels[0])*cterm->sx_width*cterm->sx_height*cterm->sx_iv*cterm->sx_ih);
if (px.pixels) {
px.height = cterm->sx_height;
px.width = cterm->sx_width;
for (i = 0; i<cterm->sx_height*cterm->sx_iv; i++) {
......@@ -1878,6 +1879,7 @@ 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);
}
}
if (cterm->extattr & CTERM_EXTATTR_SXSCROLL) {
if (vmode != -1) {
......
......@@ -67,14 +67,24 @@ main(int argc, char **argv)
fprintf(stderr, "Usage: %s <os> <path>\n", argv[0]);
return EXIT_FAILURE;
}
if (strlen(argv[2]) > sizeof(path) - 10)
return EXIT_FAILURE;
sprintf(path, "%s/rgbmap.s", argv[2]);
s = fopen(path, "w");
if (s == NULL)
return EXIT_FAILURE;
sprintf(path, "%s/rgbmap.h", argv[2]);
h = fopen(path, "w");
if (h == NULL)
return EXIT_FAILURE;
sprintf(path, "%s/r2y.bin", argv[2]);
r = fopen(path, "wb");
if (r == NULL)
return EXIT_FAILURE;
sprintf(path, "%s/y2r.bin", argv[2]);
y = fopen(path, "wb");
if (y == NULL)
return EXIT_FAILURE;
init_r2y();
if (strcmp(argv[1], "win32") == 0)
mangle = "_";
......
......@@ -533,10 +533,8 @@ int x_init(void)
}
#ifdef WITH_XRENDER
xrender_found = true;
if ((dl2 = xp_dlopen(libnames2,RTLD_LAZY,1)) == NULL) {
xp_dlclose(dl2);
if ((dl2 = xp_dlopen(libnames2,RTLD_LAZY,1)) == NULL)
xrender_found = false;
}
if (xrender_found && ((x11.XRenderFindStandardFormat = xp_dlsym(dl2, XRenderFindStandardFormat)) == NULL)) {
xp_dlclose(dl2);
xrender_found = false;
......@@ -572,10 +570,8 @@ int x_init(void)
#endif
#ifdef WITH_XINERAMA
xinerama_found = true;
if ((dl3 = xp_dlopen(libnames3,RTLD_LAZY,1)) == NULL) {
xp_dlclose(dl3);
if ((dl3 = xp_dlopen(libnames3,RTLD_LAZY,1)) == NULL)
xinerama_found = false;
}
if (xinerama_found && ((x11.XineramaQueryVersion = xp_dlsym(dl3, XineramaQueryVersion)) == NULL)) {
xp_dlclose(dl3);
xinerama_found = false;
......@@ -587,10 +583,8 @@ int x_init(void)
#endif
#ifdef WITH_XRANDR
xrandr_found = true;
if ((dl4 = xp_dlopen(libnames4,RTLD_LAZY,2)) == NULL) {
xp_dlclose(dl4);
if ((dl4 = xp_dlopen(libnames4,RTLD_LAZY,2)) == NULL)
xrandr_found = false;
}
if (xinerama_found && ((x11.XRRQueryVersion = xp_dlsym(dl4, XRRQueryVersion)) == NULL)) {
xp_dlclose(dl4);
xrandr_found = false;
......@@ -617,21 +611,81 @@ int x_init(void)
if(sem_init(&pastebuf_set, 0, 0)) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
return(-1);
}
if(sem_init(&pastebuf_used, 0, 0)) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
sem_destroy(&pastebuf_set);
return(-1);
}
if(sem_init(&init_complete, 0, 0)) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
sem_destroy(&pastebuf_set);
sem_destroy(&pastebuf_used);
return(-1);
}
if(sem_init(&mode_set, 0, 0)) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
sem_destroy(&pastebuf_set);
sem_destroy(&pastebuf_used);
sem_destroy(&init_complete);
......@@ -640,6 +694,21 @@ int x_init(void)
if(pthread_mutex_init(&copybuf_mutex, 0)) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
sem_destroy(&pastebuf_set);
sem_destroy(&pastebuf_used);
sem_destroy(&init_complete);
......@@ -651,6 +720,21 @@ int x_init(void)
sem_wait(&init_complete);
if(!x11_initialized) {
xp_dlclose(dl);
#ifdef WITH_XRENDER
if (xrender_found)
xp_dlclose(dl2);
xrender_found = false;
#endif
#ifdef WITH_XINERAMA
if (xinerama_found)
xp_dlclose(dl3);
xinerama_found = false;
#endif
#ifdef WITH_XRANDR
if (xrandr_found)
xp_dlclose(dl4);
xrandr_found = false;
#endif
sem_destroy(&pastebuf_set);
sem_destroy(&pastebuf_used);
sem_destroy(&init_complete);
......
......@@ -975,8 +975,8 @@ static int init_window()
classhints->res_class = (char *)ciolib_initial_program_class;
}
wmhints=x11.XAllocWMHints();
wmhints->flags = 0;
if(wmhints) {
wmhints->flags = 0;
wmhints->initial_state=NormalState;
wmhints->flags |= (StateHint | InputHint);
wmhints->input = True;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment