Use 64bit arithmetic to avoid overflow

The multiplication is evaluated using 32bit arithmetic, and then stored
in a 64bit integer. The 32bit integer overflow can be avoided by casting
to a 64bit type first.
This commit is contained in:
Jef Driesen 2018-03-24 13:13:09 +01:00
parent 54fef8e093
commit 2c7d1fe39f

View File

@ -691,7 +691,7 @@ dc_serial_read (dc_iostream_t *abstract, void *data, size_t size, size_t *actual
if (init) {
// Calculate the initial timeout.
timeout = device->timeout * 1000;
timeout = (dc_usecs_t) device->timeout * 1000;
// Calculate the target time.
target = now + timeout;
init = 0;