| Summary: | dereference a NULL pointer dst_fmt in SDL_CreateTextureFromSurface function | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Nitz <nitin.j4> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | ||
| Version: | 2.0.3 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
| Attachments: | patch | ||
Fixed, thanks! https://hg.libsdl.org/SDL/rev/230e7558f76a |
Created attachment 1812 [details] patch In SDL_CreateTextureFromSurface: SDL_PixelFormat *dst_fmt; /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); temp = SDL_ConvertSurface(surface, dst_fmt, 0); Here is need of NULL check for dst_fmt because there are chances of NULL return from SDL_AllocFormat(format); so it should be like that: SDL_PixelFormat *dst_fmt; SDL_Surface *temp = NULL; /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); if (!dst_fmt) { SDL_DestroyTexture(texture); return NULL; } temp = SDL_ConvertSurface(surface, dst_fmt, 0); SDL_FreeFormat(dst_fmt); Thanks!!!