From c809a8873cd7e0a9df80d18a6273b227ae2177b4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 20 Sep 2016 09:10:02 -0700 Subject: [PATCH] Second attempt to fix crash Linus pointed out that it might be another call site (and looking at his proposed patch I noticed a logic error in my earlier attempt) Signed-off-by: Dirk Hohndel --- core/device.c | 2 +- core/libdivecomputer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/device.c b/core/device.c index dde758dc8..86c30dbd9 100644 --- a/core/device.c +++ b/core/device.c @@ -193,7 +193,7 @@ static void match_id(void *_dc, const char *model, uint32_t deviceid, if (dc->deviceid != deviceid) return; - if (strcmp(dc->model, model)) + if (!model || !dc->model || strcmp(dc->model, model)) return; if (serial && !dc->serial) diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 7eea60393..25abc4d23 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -498,7 +498,7 @@ static void dc_match_serial(void *_dc, const char *model, uint32_t deviceid, con if (!deviceid) return; - if (!dc->model && (!model || strcasecmp(dc->model, model))) + if (!dc->model || !model || strcasecmp(dc->model, model)) return; if (!dc->serial || !serial || strcasecmp(dc->serial, serial)) return;