fix(pthread): configuration functions check for null pointer

This commit is contained in:
Jakob Hasse
2024-09-09 12:14:05 +02:00
parent 7834519af8
commit f9e7305efd
4 changed files with 24 additions and 0 deletions

View File

@@ -52,6 +52,10 @@ esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg)
{
// Not checking the stack size here since PTHREAD_STACK_MIN has two conflicting declarations on Linux
if (cfg == NULL) {
return ESP_ERR_INVALID_ARG;
}
// 0 is treated as default value, hence change caps to MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL in that case
int heap_caps;
if (cfg->stack_alloc_caps == 0) {
@@ -86,6 +90,10 @@ esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg)
esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p)
{
if (p == NULL) {
return ESP_ERR_INVALID_ARG;
}
esp_pthread_cfg_t *cfg = pthread_getspecific(s_pthread_cfg_key);
if (cfg) {
*p = *cfg;