Closed guijan closed 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
assert()
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
XCreateGC()
NULL
Xmalloc()
malloc(1)
malloc()
git grep 'assert(' should reveal any other faulty assertions if there are any.
git grep 'assert('
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-L79XCreateGC()
can indeed returnNULL
, as its source code explains: https://github.com/mirror/libX11/blob/5faa8dc0b364f55f19034c370436074646d9ad54/src/CrGC.c#L64-L79 It returnsNULL
ifXmalloc()
returns NULL,Xmalloc()
is a function-like macro that callsmalloc(1)
if the allocation is 0-sized and the system'smalloc()
doesn't return a unique pointer in that situation: https://github.com/mirror/libX11/blob/5faa8dc0b364f55f19034c370436074646d9ad54/include/X11/Xlibint.h#L444-L460