From 886c8e299454176446cce82f151b85a82b26aa06 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 18 Dec 2019 22:23:34 +0100 Subject: Fix evdev division by zero --- TODO | 3 ++- backends/evdev.c | 3 +++ midimonster.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 6ee649f..a5b5e7c 100644 --- a/TODO +++ b/TODO @@ -4,5 +4,6 @@ Optimize core channel search (store backend offset) udp backends may ignore MTU mm_managed_fd.impl is not freed currently (and is heaped most of the time anyway) -> documentation installer: implement an upgrade mode (check for newer versions in the repo) -evdev.c:321 divides by zero with relaxis make event collectors threadsafe to stop marshalling data... +collect & check backend API version +introduce backend logging macro diff --git a/backends/evdev.c b/backends/evdev.c index 659dc77..193b28b 100644 --- a/backends/evdev.c +++ b/backends/evdev.c @@ -208,6 +208,9 @@ static int evdev_configure_instance(instance* inst, char* option, char* value) { data->relative_axis[data->relative_axes].max *= -1; data->relative_axis[data->relative_axes].inverted = 1; } + else if(data->relative_axis[data->relative_axes].max == 0){ + fprintf(stderr, "Relative axis configuration for %s.%s has invalid range\n", inst->name, option + 8); + } data->relative_axis[data->relative_axes].current = strtoul(next_token, NULL, 0); if(data->relative_axis[data->relative_axes].code < 0){ fprintf(stderr, "Failed to configure relative axis extents for %s.%s\n", inst->name, option + 8); diff --git a/midimonster.c b/midimonster.c index 48c6fe9..2ec165b 100644 --- a/midimonster.c +++ b/midimonster.c @@ -224,7 +224,7 @@ static void event_free(){ } static void version(){ - fprintf(stdout, "MIDIMonster %s\n", MIDIMONSTER_VERSION); + printf("MIDIMonster %s\n", MIDIMONSTER_VERSION); } static int usage(char* fn){ -- cgit v1.2.3