Explorar o código

Changed example code to avoid potential divide by zero

Sam Lantinga %!s(int64=2) %!d(string=hai) anos
pai
achega
279ff8909f
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      docs/README-migration.md

+ 4 - 2
docs/README-migration.md

@@ -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 bytes = SDL_RWread(stream, ptr, size * nitems);
-    return (bytes / size);
+    if (size > 0 && nitems > 0) {
+        return SDL_RWread(stream, ptr, size * nitems) / size;
+    }
+    return 0;
 }
 ```