On Tue, Sep 20, 2016 at 9:05 AM, Linus Torvalds
<[email protected]> wrote:
>
> In all *normal* situations, dc->model is non-NULL, but I think we
> *can* have a NULL model for a dive that was added manually.
Maybe something like this. You probably already did the dc_match_serial() part.
Linus
core/device.c | 2 +-
core/libdivecomputer.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/core/device.c b/core/device.c
index dde758dc831d..86c30dbd97e0 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 e8cfb3521de7..94fc63f764e5 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -493,9 +493,9 @@ static void dc_match_serial(void *_dc, const char *model,
uint32_t deviceid, con
if (!deviceid)
return;
- if (!model || strcasecmp(dc->model, model))
+ if (!model || !dc->model || strcasecmp(dc->model, model))
return;
- if (!serial || strcasecmp(dc->serial, serial))
+ if (!serial || !dc->serial strcasecmp(dc->serial, serial))
return;
dc->deviceid = deviceid;
}
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface