We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f81c7b3 commit b80d86fCopy full SHA for b80d86f
1 file changed
src/O2FS/Systems/O2MusicSystem.cpp
@@ -91,9 +91,14 @@ namespace O2FS
91
// Convert the BMS into OJN file.
92
auto data = LoadChart(hFile);
93
94
+ // Calculate the number of bytes to read to avoid out of range error
95
+ int count = nNumberOfBytesToRead;
96
+ if (offset + count > data.size())
97
+ count = data.size() - offset;
98
+
99
// Fill the buffer with converted OJN data at requested offset
- memcpy(&buffer[0], &data[offset], nNumberOfBytesToRead);
- *lpNumberOfBytesRead = nNumberOfBytesToRead;
100
+ memcpy(&buffer[0], &data[offset], count);
101
+ *lpNumberOfBytesRead = count;
102
103
// Release the HANDLE lock so the HANDLE can be hooked again after this call.
104
handles.erase(fileName);
0 commit comments