From e00e1bb9f7c0e00dd39a8de20d5bc4834cc117f4 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 23 Jan 2024 09:59:59 -0500 Subject: [PATCH] Downloader: fix segfault With no files given and no config present, the downloader segfaults due to empty `files`. Print a message instead. Signed-off-by: Richard Fuchs --- subsurface-downloader-main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/subsurface-downloader-main.cpp b/subsurface-downloader-main.cpp index 7e91fe6e0..354ff1278 100644 --- a/subsurface-downloader-main.cpp +++ b/subsurface-downloader-main.cpp @@ -102,7 +102,14 @@ int main(int argc, char **argv) cliDownloader(prefs.dive_computer.vendor, prefs.dive_computer.product, prefs.dive_computer.device); } } - save_dives(qPrintable(files.first())); + if (!files.isEmpty()) { + qDebug() << "saving dive data to" << files; + save_dives(qPrintable(files.first())); + } + else { + printf("No log files given, not saving dive data.\n"); + printf("Give a log file name as argument, or configure a cloud URL.\n"); + } clear_divelog(&divelog); taglist_free(g_tag_list); parse_xml_exit();