diff options
author | Simon Ser <contact@emersion.fr> | 2019-11-03 00:53:57 +0100 |
---|---|---|
committer | Scott Anderson <scott@anderso.nz> | 2019-11-03 00:15:05 +0000 |
commit | a2aee4ab10ecfdd6d059aa2f5f42316fcda6c3eb (patch) | |
tree | 7dfb248a137606487a95241d6eaf12890319855c | |
parent | f90c3205f6e5ae353583c751b4e381a04971b6bc (diff) | |
download | external_drm_info-a2aee4ab10ecfdd6d059aa2f5f42316fcda6c3eb.tar.gz external_drm_info-a2aee4ab10ecfdd6d059aa2f5f42316fcda6c3eb.tar.bz2 external_drm_info-a2aee4ab10ecfdd6d059aa2f5f42316fcda6c3eb.zip |
Fix segfault on drmGetDevices failure
When no DRM devices are detected, drm_info fails with:
drmGetDevices: No such file or directory
And then segfaults. This happens because the drm_info() function returns
a NULL pointer on failure but main() doesn't handle it.
-rw-r--r-- | main.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -26,6 +26,9 @@ int main(int argc, char *argv[]) } struct json_object *obj = drm_info(&argv[optind]); + if (!obj) { + exit(EXIT_FAILURE); + } if (json) { json_object_to_fd(STDOUT_FILENO, obj, JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED); |