mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Linux: Fix memory leak when inotify init failed
This introduces regex_compiled boolean to track whether the regex is
compiled successfully.
Closes #2229
(cherry picked from commit c992226a9c
)
This commit is contained in:
parent
6f9686f1f4
commit
7c7cc59889
@ -283,7 +283,9 @@ GLFWbool _glfwInitJoysticksLinux(void)
|
||||
|
||||
// Continue without device connection notifications if inotify fails
|
||||
|
||||
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
|
||||
_glfw.linjs.regex_compiled = regcomp(&_glfw.linjs.regex,
|
||||
"^event[0-9]\\+$", 0) == 0;
|
||||
if (!_glfw.linjs.regex_compiled)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
|
||||
return GLFW_FALSE;
|
||||
@ -342,6 +344,9 @@ void _glfwTerminateJoysticksLinux(void)
|
||||
|
||||
close(_glfw.linjs.inotify);
|
||||
}
|
||||
|
||||
if (_glfw.linjs.regex_compiled)
|
||||
regfree(&_glfw.linjs.regex);
|
||||
}
|
||||
|
||||
void _glfwDetectJoystickConnectionLinux(void)
|
||||
|
@ -53,6 +53,7 @@ typedef struct _GLFWlibraryLinux
|
||||
int inotify;
|
||||
int watch;
|
||||
regex_t regex;
|
||||
GLFWbool regex_compiled;
|
||||
GLFWbool dropped;
|
||||
} _GLFWlibraryLinux;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user