| Summary: | Wrong coding practise in src/video/x11/SDL_x11events.c file, may cause an crash | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Nitz <nitin.j4> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | 2.0.0 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
This does short-circuit evaluation, so if videodata is NULL, the if condition will be false and videodata->windowlist will not be evaluated. Thanks for checking though! |
in function, static void X11_DispatchEvent(_THIS) { // Some Code if (videodata && videodata->windowlist) { for (i = 0; i < videodata->numwindows; ++i) { if ((videodata->windowlist[i] != NULL) && (videodata->windowlist[i]->xwindow == xevent.xany.window)) { data = videodata->windowlist[i]; break; } } } // Some Code } In the if condition, if (videodata && videodata->windowlist) videodata is dereferenced while checking the videodata, if videodata will be NULL then it may cause an crash. So videodata should be dereferenced after the NULL check.