From 4507f8d7a835ed26b2aa9f9a3f1878bbd6c5f07b Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Thu, 28 May 2020 22:11:28 -0400 Subject: [PATCH] Fix crash when trying to import Weinmann SOMNObalance e. This patch only addresses the crash, it doesn't add support for the machine. --- oscar/SleepLib/loader_plugins/weinmann_loader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oscar/SleepLib/loader_plugins/weinmann_loader.cpp b/oscar/SleepLib/loader_plugins/weinmann_loader.cpp index 9516ebce..4fd6c4ab 100644 --- a/oscar/SleepLib/loader_plugins/weinmann_loader.cpp +++ b/oscar/SleepLib/loader_plugins/weinmann_loader.cpp @@ -1,6 +1,7 @@ -/* SleepLib Weinmann SOMNOsoft/Balance Loader Implementation +/* SleepLib Weinmann SOMNOsoft/Balance Loader Implementation * * Copyright (c) 2011-2018 Mark Watkins + * Copyright (c) 2020 The OSCAR Team * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of the source code @@ -179,6 +180,12 @@ int WeinmannLoader::Open(const QString & dirpath) int comp_end = index[FlowOffset]; int comp_size = comp_end - comp_start; + // TODO: This entire loader needs significant work. For now just + // hard-code values here to make sure we don't crash in the loop below. + if (comp_size < 5 * 0xd6) { + qWarning() << "Weinmann loader comp_size too short:" << comp_size; + return -1; + } quint8 * comp = new quint8 [comp_size]; memset((char *)comp, 0, comp_size);