File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -101,11 +101,17 @@ class Pool {
101
101
umf_result_t ret;
102
102
char ret_buf[256 ] = {0 };
103
103
if constexpr (std::is_same_v<T, std::string>) {
104
- strncpy (ret_buf, value.c_str (), sizeof (ret_buf));
104
+ strncpy (ret_buf, value.c_str (), sizeof (ret_buf) - 1 );
105
+ ret_buf[sizeof (ret_buf) - 1 ] = ' \0 ' ; // Ensure null-termination
106
+ ret = ctlApiFunction (name, disableContext ? nullptr : pool,
107
+ (void *)ret_buf, sizeof (ret_buf));
108
+ } else if constexpr (std::is_arithmetic_v<T>) {
109
+ std::string value_str = std::to_string (value);
110
+ strncpy (ret_buf, value_str.c_str (), sizeof (ret_buf) - 1 );
111
+ ret_buf[sizeof (ret_buf) - 1 ] = ' \0 ' ; // Ensure null-termination
105
112
ret = ctlApiFunction (name, disableContext ? nullptr : pool,
106
113
(void *)ret_buf, sizeof (ret_buf));
107
114
} else {
108
- strncpy (ret_buf, value, sizeof (value));
109
115
ret = ctlApiFunction (name, disableContext ? nullptr : pool, &value,
110
116
sizeof (value));
111
117
}
You can’t perform that action at this time.
0 commit comments