diff options
author | Campbell Barton <campbell@blender.org> | 2022-07-09 15:27:26 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-07-09 15:27:26 +0300 |
commit | b5d22a8134ac3bfc6c084b836729f4dd15e25bee (patch) | |
tree | 16da1b6dc5a4fec8bd67f1b7ad8f6a8183ed09ac /intern/ghost | |
parent | 80f8b7cbbb562c6967ba81c76027a984cd9cd9b6 (diff) |
Fix resource leaks setting custom cursors in Wayland
- Memory from the prior cursor was never un-mapped.
- posix_fallocate failure left a file handle open..
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWayland.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 08aa640c5cd..76e5329a410 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -3347,6 +3347,11 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap, cursor_t *cursor = &d->inputs[0]->cursor; + if (cursor->file_buffer->data) { + munmap(cursor->file_buffer->data, cursor->file_buffer->size); + cursor->file_buffer->data = nullptr; + } + static const int32_t stride = sizex * 4; /* ARGB */ cursor->file_buffer->size = (size_t)stride * sizey; @@ -3376,6 +3381,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(uint8_t *bitmap, } if (UNLIKELY(posix_fallocate(fd, 0, int32_t(cursor->file_buffer->size)) != 0)) { + close(fd); return GHOST_kFailure; } |