get_device_info(): don't leak free()'ed pointer on error#886
Merged
whot merged 1 commit intolinuxwacom:masterfrom Jun 15, 2025
Merged
get_device_info(): don't leak free()'ed pointer on error#886whot merged 1 commit intolinuxwacom:masterfrom
whot merged 1 commit intolinuxwacom:masterfrom
Conversation
Programs using libwacom on a system without any supported
device are being subject to a segfault:
malloc_consolidate(): unaligned fastbin chunk detected
Abandon (core dumped)
Using valgrind on list-local-devices shows the issue:
==29751== Command: ./list-local-devices
==29751==
==29751== Invalid free() / delete / delete[] / realloc()
==29751== at 0x4842E43: free (vg_replace_malloc.c:989)
==29751== by 0x48D8D44: g_free (gmem.c:208)
==29751== by 0x485BD8B: g_autoptr_cleanup_generic_gfree (glib-autocleanups.h:32)
==29751== by 0x485DCC2: libwacom_new_from_path (libwacom.c:790)
==29751== by 0x4014B0: main (list-local-devices.c:301)
==29751== Address 0x5234aa0 is 0 bytes inside a block of size 28 free'd
==29751== at 0x4842E43: free (vg_replace_malloc.c:989)
==29751== by 0x48D8D44: g_free (gmem.c:208)
==29751== by 0x485C9ED: get_device_info (libwacom.c:369)
==29751== by 0x485DBE9: libwacom_new_from_path (libwacom.c:799)
==29751== by 0x4014B0: main (list-local-devices.c:301)
==29751== Block was alloc'd at
==29751== at 0x483FB26: malloc (vg_replace_malloc.c:446)
==29751== by 0x48DE9E9: g_malloc (gmem.c:100)
==29751== by 0x48F8AB9: g_strdup (gstrfuncs.c:323)
==29751== by 0x485C4F9: g_strdup_inline (gstrfuncs.h:321)
==29751== by 0x485C4F9: get_device_prop (libwacom.c:228)
==29751== by 0x485C8C8: get_device_info (libwacom.c:342)
==29751== by 0x485DBE9: libwacom_new_from_path (libwacom.c:799)
==29751== by 0x4014B0: main (list-local-devices.c:301)
==29751==
Failed to find any devices known to libwacom.
In case of error in get_device_info(), pointer being released
must not be returned to the caller.
Member
|
thanks! |
whot
added a commit
to whot/libwacom
that referenced
this pull request
Jun 15, 2025
This would've prevented linuxwacom#886
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jun 15, 2025
This would've prevented #886
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Programs using libwacom on a system without any supported device are being subject to a segfault:
Using valgrind on list-local-devices shows the issue:
In case of error in get_device_info(), pointer being released must not be returned to the caller.