mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Check for 0 input when setting max_background_thread through mallctl.
Reported by @nc7s.
This commit is contained in:
@@ -2181,7 +2181,8 @@ max_background_threads_ctl(tsd_t *tsd, const size_t *mib,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
if (newval > opt_max_background_threads) {
|
if (newval > opt_max_background_threads ||
|
||||||
|
newval == 0) {
|
||||||
ret = EINVAL;
|
ret = EINVAL;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ TEST_BEGIN(test_max_background_threads) {
|
|||||||
"opt.max_background_threads should match");
|
"opt.max_background_threads should match");
|
||||||
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &max_n_thds,
|
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &max_n_thds,
|
||||||
sz_m), 0, "Failed to set max background threads");
|
sz_m), 0, "Failed to set max background threads");
|
||||||
|
size_t size_zero = 0;
|
||||||
|
expect_d_ne(mallctl("max_background_threads", NULL, NULL, &size_zero,
|
||||||
|
sz_m), 0, "Should not allow zero background threads");
|
||||||
|
|
||||||
unsigned id;
|
unsigned id;
|
||||||
size_t sz_u = sizeof(unsigned);
|
size_t sz_u = sizeof(unsigned);
|
||||||
@@ -80,6 +83,8 @@ TEST_BEGIN(test_max_background_threads) {
|
|||||||
new_max_thds = 1;
|
new_max_thds = 1;
|
||||||
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &new_max_thds,
|
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &new_max_thds,
|
||||||
sz_m), 0, "Failed to set max background threads");
|
sz_m), 0, "Failed to set max background threads");
|
||||||
|
expect_d_ne(mallctl("max_background_threads", NULL, NULL, &size_zero,
|
||||||
|
sz_m), 0, "Should not allow zero background threads");
|
||||||
expect_zu_eq(n_background_threads, new_max_thds,
|
expect_zu_eq(n_background_threads, new_max_thds,
|
||||||
"Number of background threads should be 1.\n");
|
"Number of background threads should be 1.\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user