OSDN Git Service

Fix off-by-one error in DirectSound backend
authorAlaskanEmily <emily@alaskanemily.net>
Sun, 7 Jul 2019 17:43:16 +0000 (10:43 -0700)
committerAlaskanEmily <emily@alaskanemily.net>
Sun, 7 Jul 2019 17:43:16 +0000 (10:43 -0700)
src/dsound/cin_dsound_sound.cpp

index 7ce3dbe..1344c0c 100755 (executable)
@@ -105,10 +105,16 @@ Cin_Sound::Cin_Sound(IDirectSound8 *dsound, const Cin_Loader &ld)
     fmt.Format.wBitsPerSample = bytes_per_sample << 3;\r
 \r
     // Check the size of the loader data.\r
-    unsigned byte_size = 0;\r
-    for(const struct Cin_LoaderData *i = ld.first, *const end = ld.last; i != end; i = i->next){\r
-        byte_size += i->len;\r
+    const unsigned byte_size = ld.bytes_placed;\r
+#ifndef NDEBUG\r
+    {\r
+        unsigned debug_byte_size = 0;\r
+        for(const struct Cin_LoaderData *i = ld.first; i != NULL; i = i->next){\r
+            debug_byte_size += i->len;\r
+        }\r
+        assert(debug_byte_size == byte_size);\r
     }\r
+#endif\r
 \r
     DSBUFFERDESC descriptor;\r
     descriptor.dwSize = sizeof(DSBUFFERDESC);\r