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

Fix a couple issues found by Coverity

1) Unreachable return without a lock in sdl_useR_func_ret() (harmless)
2) LOR in handling SDL_USEREVENT
   - vstatlock was obtained inside of win_mutex which should never
     be done... this could (and likely does) result in a deadlock
     when using SDL mode.
parent 7d3305fe
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3760 passed
...@@ -230,6 +230,7 @@ static void sdl_user_func(int func, ...) ...@@ -230,6 +230,7 @@ static void sdl_user_func(int func, ...)
case SDL_USEREVENT_FLUSH: case SDL_USEREVENT_FLUSH:
break; break;
default: default:
pthread_mutex_unlock(&sdl_ufunc_mtx);
va_end(argptr); va_end(argptr);
return; return;
} }
...@@ -1058,6 +1059,7 @@ void sdl_video_event_thread(void *data) ...@@ -1058,6 +1059,7 @@ void sdl_video_event_thread(void *data)
sem_post(&sdl_ufunc_ret); sem_post(&sdl_ufunc_ret);
return; return;
case SDL_USEREVENT_FLUSH: case SDL_USEREVENT_FLUSH:
pthread_mutex_lock(&vstatlock);
pthread_mutex_lock(&win_mutex); pthread_mutex_lock(&win_mutex);
if (win != NULL) { if (win != NULL) {
pthread_mutex_lock(&sdl_headlock); pthread_mutex_lock(&sdl_headlock);
...@@ -1079,7 +1081,6 @@ void sdl_video_event_thread(void *data) ...@@ -1079,7 +1081,6 @@ void sdl_video_event_thread(void *data)
int tw, th; int tw, th;
sdl.RenderClear(renderer); sdl.RenderClear(renderer);
pthread_mutex_lock(&vstatlock);
if (internal_scaling) { if (internal_scaling) {
struct graphics_buffer *gb; struct graphics_buffer *gb;
int xscale, yscale; int xscale, yscale;
...@@ -1150,7 +1151,6 @@ void sdl_video_event_thread(void *data) ...@@ -1150,7 +1151,6 @@ void sdl_video_event_thread(void *data)
dst.x = (cvstat.winwidth - dst.w) / 2; dst.x = (cvstat.winwidth - dst.w) / 2;
dst.y = (cvstat.winheight - dst.h) / 2; dst.y = (cvstat.winheight - dst.h) / 2;
} }
pthread_mutex_unlock(&vstatlock);
if (sdl.RenderCopy(renderer, texture, &src, &dst)) if (sdl.RenderCopy(renderer, texture, &src, &dst))
fprintf(stderr, "RenderCopy() failed! (%s)\n", sdl.GetError()); fprintf(stderr, "RenderCopy() failed! (%s)\n", sdl.GetError());
} }
...@@ -1160,6 +1160,7 @@ void sdl_video_event_thread(void *data) ...@@ -1160,6 +1160,7 @@ void sdl_video_event_thread(void *data)
} }
pthread_mutex_unlock(&win_mutex); pthread_mutex_unlock(&win_mutex);
pthread_mutex_unlock(&vstatlock);
break; break;
case SDL_USEREVENT_SETNAME: case SDL_USEREVENT_SETNAME:
pthread_mutex_lock(&win_mutex); pthread_mutex_lock(&win_mutex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment