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:
parent
54fef8e093
commit
2c7d1fe39f
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user