1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

fix possible segfault due to non-functional range check with unsigned int

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2023-10-31 15:53:42 +01:00 committed by Niklas Eiling
parent c3d991b23e
commit f09e6e909b

View file

@ -310,16 +310,17 @@ int Node::write(struct Sample *smps[], unsigned cnt) {
#ifdef WITH_HOOKS
// Run write hooks
cnt = out.hooks.process(smps, cnt);
if (cnt <= 0)
return cnt;
int hook_cnt = out.hooks.process(smps, cnt);
if (hook_cnt <= 0)
return hook_cnt;
cnt = hook_cnt;
#endif // WITH_HOOKS
vect = getFactory()->getVectorize();
if (!vect)
vect = cnt;
while (cnt - nsent > 0) {
while (cnt > static_cast<unsigned>(nsent)) {
tosend = MIN(cnt - nsent, vect);
sent = _write(&smps[nsent], tosend);
if (sent < 0)