resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
495 stars 49 forks source link

unchecked NULL return in Xlib call #268

Closed guijan closed 1 year ago

guijan commented 1 year ago

This shouldn't be an assert(), it should be in the release build: https://github.com/resurrecting-open-source-projects/scrot/blob/5b515d636ed6366dfab73a72f4c9b59fdcd6ea0d/src/selection_classic.c#L75-L79

XCreateGC() can indeed return NULL, as its source code explains: https://github.com/mirror/libX11/blob/5faa8dc0b364f55f19034c370436074646d9ad54/src/CrGC.c#L64-L79 It returns NULL if Xmalloc() returns NULL, Xmalloc() is a function-like macro that calls malloc(1) if the allocation is 0-sized and the system's malloc() doesn't return a unique pointer in that situation: https://github.com/mirror/libX11/blob/5faa8dc0b364f55f19034c370436074646d9ad54/include/X11/Xlibint.h#L444-L460

N-R-K commented 1 year ago

git grep 'assert(' should reveal any other faulty assertions if there are any.