diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 13:22:28 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 13:33:26 +0100 |
| commit | 838d75bce98ca5a1f90f762e80d2aa649d4e0642 (patch) | |
| tree | 06d661dd944d80632aa80a9f605a679779575dc5 /src/fs.c | |
| parent | e51027a576a07ffb41b6e7d2bfc3aade6ae091d7 (diff) | |
Minor Fixes
Diffstat (limited to 'src/fs.c')
| -rw-r--r-- | src/fs.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -829,10 +829,14 @@ uint8_t *pw_fs_write(struct pw_fs *fs, pw_fd fd, uint32_t len) { w->capacity = capacity; } + // We cannot know for sure that the caller will actually write the + // data to the buffer, which means that it is possible for us to sync + // uninitialized malloc data which would be undefined behaviour. To + // prevent this, always clear the new portions of the buffer. Note that // POSIX requires holes to be filled with 0s (in case the file was - // seeked past the end). - if (s->pos > w->size) { - SDL_memset(w->data + w->size, 0, s->pos - w->size); + // seeked past the end), so we satisfy that as well. + if (end > w->size) { + SDL_memset(w->data + w->size, 0, end - w->size); } uint8_t *buffer = w->data + s->pos; |
