resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
511 stars 51 forks source link

remove some useless assert()s #299

Closed guijan closed 1 year ago

guijan commented 1 year ago

All of the removed assert()s are checking whether pointers that are soon to be dereferenced by scrot are NULL. There are many more pointers in the source code that don't get assert()ed and any OS these days will have NULL == 0 and an unmapped 0-page that causes the program to segfault on read/write, the exception would be MMU-less systems, but we don't expect people to develop on those.

The only exception is scrotGetWindowName(), but the assert() redundantly checks if the function's argument is NULL, when its only caller already does that without assert().

N-R-K commented 1 year ago

Merged manually in 07d0ccf6d7326394200b5109c62665f569d27e23. Only change is I added back the window assert. Wanted to merge this since I was going to replace the asserts with a custom variant and wanted to avoid conflicts.