cursor: Theme that inherits itself causes infinite recursion
This was originally reported as https://bugs.kde.org/show_bug.cgi?id=457926
While of course nonsensical it is possible to write an xcursor theme that inherits itself, either directly or indirectly
This will cause infinite recursion when loading the theme via libwayland-cursor
A sample file is mentioned in the original report.
Backtrace from an affected application:
#0 __GI___libc_read (nbytes=4096, buf=0x17d2bf0, fd=29) at ../sysdeps/unix/sysv/linux/read.c:26
#1 __GI___libc_read (fd=29, buf=0x17d2bf0, nbytes=4096) at ../sysdeps/unix/sysv/linux/read.c:24
#2 0x00007f75baa5c5b8 in _IO_new_file_seekoff (fp=0x155a000, offset=28, dir=<optimized out>, mode=<optimized out>) at fileops.c:1015
#3 0x00007f75baa59523 in __GI_fseek (fp=0x155a000, offset=28, whence=0) at fseek.c:36
#4 0x00007f75b78e2486 in _XcursorSeekToToc (toc=<optimized out>, fileHeader=0x16f4470, file=0x7ffe83376ef0) at ../cursor/xcursor.c:375
#5 _XcursorFileReadChunkHeader (chunkHeader=0x7ffe83376ee0, toc=<optimized out>, fileHeader=0x16f4470, file=0x7ffe83376ef0) at ../cursor/xcursor.c:388
#6 _XcursorReadImage (toc=<optimized out>, fileHeader=0x16f4470, file=0x7ffe83376ef0) at ../cursor/xcursor.c:478
#7 XcursorXcFileLoadImages (size=24, file=0x7ffe83376ef0) at ../cursor/xcursor.c:555
#8 XcursorFileLoadImages (size=24, file=0x155a000) at ../cursor/xcursor.c:609
#9 load_all_cursors_from_dir (load_callback=0x7f75b78e1bf0 <load_callback>, user_data=0x12db8c0, size=24, path=0x16f3b30 "/home/nico/.icons/VS5/cursors/") at ../cursor/xcursor.c:932
#10 xcursor_load_theme (theme=theme@entry=0x17cab00 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:989
#11 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17caa70 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#12 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca9e0 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#13 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca950 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#14 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca8c0 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#15 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca830 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#16 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca7a0 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#17 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca710 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#18 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca680 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#19 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca5f0 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#20 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca560 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
#21 0x00007f75b78e268d in xcursor_load_theme (theme=theme@entry=0x17ca4d0 "VS5", size=size@entry=24, user_data=user_data@entry=0x12db8c0, load_callback=0x7f75b78e1bf0 <load_callback>) at ../cursor/xcursor.c:1006
Observed with wayland 1.20.0 on Fedora 36