[client,X11] avoid dynamic allocation of devName

This commit is contained in:
ichaoX 2023-09-13 16:03:30 +08:00 committed by akallabeth
parent a28920f3ed
commit 4935b0978b

View File

@ -30,7 +30,6 @@
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
#endif #endif
#include <ctype.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <limits.h> #include <limits.h>
@ -143,11 +142,10 @@ static BOOL register_input_events(xfContext* xfc, Window window)
{ {
double max_pressure = t->max; double max_pressure = t->max;
char* devName = _strdup(dev->name); char devName[200];
if (!devName) strncpy(devName, dev->name, 200);
break; devName[200 - 1] = '\0';
for (size_t k = 0; k < strlen(devName); k++) CharLowerBuffA(devName, (DWORD)strlen(devName));
devName[k] = (char)tolower(devName[k]);
if (strstr(devName, "eraser") != NULL) if (strstr(devName, "eraser") != NULL)
{ {
@ -166,7 +164,6 @@ static BOOL register_input_events(xfContext* xfc, Window window)
dev->deviceid, max_pressure)) dev->deviceid, max_pressure))
WLog_DBG(TAG, "registered pen"); WLog_DBG(TAG, "registered pen");
} }
free(devName);
} }
break; break;
} }