| Summary: | SDL_Vulkan_GetInstanceExtensions rejects an output array that is too large | ||
|---|---|---|---|
| Product: | SDL | Reporter: | John Bartholomew <jpa.bartholomew> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | trivial | ||
| Priority: | P2 | ||
| Version: | 2.0.7 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
Patch to allow GetInstanceExtensions output array larger than required (UNTESTED but simple)
Fixed patch to actually set *userCount as it should. |
||
Created attachment 3139 [details]
Fixed patch to actually set *userCount as it should.
And of course despite being simple I messed up the first attempt at a fix.
Added, thanks! https://hg.libsdl.org/SDL/rev/922c27f2fa56 |
Created attachment 3134 [details] Patch to allow GetInstanceExtensions output array larger than required (UNTESTED but simple) The doc comment for SDL_Vulkan_GetInstanceExtensions says: * If \a pNames is \c NULL, then the number of required Vulkan instance * extensions is returned in pCount. Otherwise, \a pCount must point to a * variable set to the number of elements in the \a pNames array, and on * return the variable is overwritten with the number of names actually * written to \a pNames. If \a pCount is less than the number of required * extensions, at most \a pCount structures will be written. If \a pCount * is smaller than the number of required extensions, \c SDL_FALSE will be * returned instead of \c SDL_TRUE, to indicate that not all the required * extensions were returned. But the code actually returns false not just if *pCount is smaller than required, but also if it is *larger* than required. In particular, this call pattern fails: const char *names[16] = {}; // Big enough for most purposes. unsigned int count = 16; if (!SDL_Vulkan_GetInstanceExtensions(window, &count, names)) { abort(); } // ... This fails even though 16 is far more than the number of required extensions because the code (SDL_Vulkan_GetInstanceExtensions_Helper) does: if(*userCount != nameCount) { SDL_SetError( "Count doesn't match count from previous call of SDL_Vulkan_GetInstanceExtensions"); return SDL_FALSE; } (userCount is pCount, nameCount is the number of extensions that need to be stored in the array)