mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-18 12:25:39 +00:00
Changed example code to avoid potential divide by zero
This commit is contained in:
@@ -925,8 +925,10 @@ should be changed to:
|
|||||||
```
|
```
|
||||||
size_t custom_read(void *ptr, size_t size, size_t nitems, SDL_RWops *stream)
|
size_t custom_read(void *ptr, size_t size, size_t nitems, SDL_RWops *stream)
|
||||||
{
|
{
|
||||||
size_t bytes = SDL_RWread(stream, ptr, size * nitems);
|
if (size > 0 && nitems > 0) {
|
||||||
return (bytes / size);
|
return SDL_RWread(stream, ptr, size * nitems) / size;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user