plugin: use safe_strdup() instead of strdup()

safe_strdup() handles NULL correctly instead of just blowing up. This
shouldn't matter because without a name our plugins won't get here but
let's do this anwyay.

Co-Authored-by: Claude Code <noreply@anthropic.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1467>
This commit is contained in:
Peter Hutterer 2026-04-16 10:27:29 +10:00 committed by Marge Bot
parent d97983ee5e
commit c276c9579e
2 changed files with 2 additions and 2 deletions

View file

@ -168,7 +168,7 @@ lua_push_evdev_device(lua_State *L,
lua_device->bustype = libinput_device_get_id_bustype(device);
lua_device->vid = libinput_device_get_id_vendor(device);
lua_device->pid = libinput_device_get_id_product(device);
lua_device->name = strdup(libinput_device_get_name(device));
lua_device->name = safe_strdup(libinput_device_get_name(device));
lua_device->device_removed_refid = LUA_NOREF;
lua_device->frame_refid = LUA_NOREF;
list_init(&lua_device->udev_properties_list);

View file

@ -115,7 +115,7 @@ libinput_plugin_new(struct libinput *libinput,
plugin->refcount = 1;
plugin->interface = interface;
plugin->user_data = user_data;
plugin->name = strdup(name);
plugin->name = safe_strdup(name);
list_init(&plugin->timers);
if (plugin->index >= 32) {