diff options
author | Richard Hughes <richard@hughsie.com> | 2022-04-13 14:14:07 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2022-04-13 14:42:28 +0100 |
commit | c357ea2e1f65b5127a33960e89163245355a4d7c (patch) | |
tree | bf155cef457c7bb4dee016f3efe020a3e3312549 | |
parent | 41bf6b99a11ccf4235aa946a3bc9fc37ea4ee4d9 (diff) | |
download | colord-c357ea2e1f65b5127a33960e89163245355a4d7c.tar.gz |
huey: Fix potential crash when reading from broken hardware
-rw-r--r-- | src/sensors/huey/huey-ctx.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/sensors/huey/huey-ctx.c b/src/sensors/huey/huey-ctx.c index fa9052e..09f83ea 100644 --- a/src/sensors/huey/huey-ctx.c +++ b/src/sensors/huey/huey-ctx.c @@ -309,9 +309,12 @@ huey_ctx_take_sample (HueyCtx *ctx, CdSensorCap cap, GError **error) color_native.R, color_native.G, color_native.B); /* try to fill the 16 bit register for accuracy */ - multiplier.R = HUEY_POLL_FREQUENCY / color_native.R; - multiplier.G = HUEY_POLL_FREQUENCY / color_native.G; - multiplier.B = HUEY_POLL_FREQUENCY / color_native.B; + if (color_native.R != 0) + multiplier.R = HUEY_POLL_FREQUENCY / color_native.R; + if (color_native.G != 0) + multiplier.G = HUEY_POLL_FREQUENCY / color_native.G; + if (color_native.B != 0) + multiplier.B = HUEY_POLL_FREQUENCY / color_native.B; /* don't allow a value of zero */ if (multiplier.R == 0) |