aboutsummaryrefslogtreecommitdiff
path: root/vm_ui.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 22:31:18 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 22:31:18 +0100
commitd405ab264332903f908a5668bb95cf05cc43e8c7 (patch)
tree454ed4631b6aecb4fd88bb5e8eb319862caf911e /vm_ui.c
parentbe915d440188230da70de05925e4bbd19cfa4127 (diff)
downloadvm.lv2-d405ab264332903f908a5668bb95cf05cc43e8c7.tar.xz
fix memory indexing overflow.
Diffstat (limited to 'vm_ui.c')
-rw-r--r--vm_ui.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vm_ui.c b/vm_ui.c
index c446197..85f37d5 100644
--- a/vm_ui.c
+++ b/vm_ui.c
@@ -31,7 +31,8 @@
# undef Bool
#endif
-#define PLOT_MAX 256
+#define PLOT_MAX 256
+#define PLOT_MASK (PLOT_MAX - 1)
typedef struct _atom_ser_t atom_ser_t;
typedef struct _plot_t plot_t;
@@ -674,7 +675,8 @@ port_event(LV2UI_Handle instance, uint32_t index, uint32_t size,
{
handle->inp[i].pre = frac;
- const unsigned pre = floorf(intp);
+ unsigned pre = floorf(intp);
+ pre &= PLOT_MASK;
const unsigned post = PLOT_MAX - pre;
memcpy(mem, &handle->inp[i].vals[pre], sizeof(float)*post);
@@ -699,7 +701,8 @@ port_event(LV2UI_Handle instance, uint32_t index, uint32_t size,
{
handle->outp[i].pre = frac;
- const unsigned pre = floorf(intp);
+ unsigned pre = floorf(intp);
+ pre &= PLOT_MASK;
const unsigned post = PLOT_MAX - pre;
memcpy(mem, &handle->outp[i].vals[pre], sizeof(float)*post);