Make sure max_dispatch_callbacks is never negative

Suggested by Alexander Drozdov.
This commit is contained in:
Nick Mathewson 2011-08-11 11:59:23 -04:00
parent fd4de1e7fe
commit 9fa56bdf1c

View File

@ -923,7 +923,7 @@ event_config_new(void)
TAILQ_INIT(&cfg->entries); TAILQ_INIT(&cfg->entries);
cfg->max_dispatch_interval.tv_sec = -1; cfg->max_dispatch_interval.tv_sec = -1;
cfg->max_dispatch_callbacks = -1; cfg->max_dispatch_callbacks = INT_MAX;
return (cfg); return (cfg);
} }
@ -1002,7 +1002,8 @@ event_config_set_max_dispatch_interval(struct event_config *cfg,
sizeof(struct timeval)); sizeof(struct timeval));
else else
cfg->max_dispatch_interval.tv_sec = -1; cfg->max_dispatch_interval.tv_sec = -1;
cfg->max_dispatch_callbacks = max_callbacks; cfg->max_dispatch_callbacks =
max_callbacks >= 0 ? max_callbacks : INT_MAX ;
return (0); return (0);
} }