|
3 | 3 |
|
4 | 4 | static void conf_auth_http_init(conf_auth_http **conf) |
5 | 5 | { |
6 | | - *conf = nng_alloc(sizeof(conf_auth_http)); |
| 6 | + *conf = nng_zalloc(sizeof(conf_auth_http)); |
7 | 7 | if (*conf == NULL) { |
8 | 8 | return; |
9 | 9 | } |
10 | | - (*conf)->enable = true; |
11 | | - (*conf)->acl_req.header_count = 0; |
| 10 | + |
| 11 | + // Explicitly initialize key fields to avoid using uninitialized |
| 12 | + // cache_ttl/acl_cache_mtx in nmq_auth_http_sub_pub during tests. |
| 13 | + (*conf)->enable = true; |
| 14 | + (*conf)->timeout = 0; |
| 15 | + (*conf)->connect_timeout = 0; |
| 16 | + (*conf)->pool_size = 0; |
| 17 | + (*conf)->cache_ttl = 0; // Ensure ACL cache branch is skipped |
| 18 | + (*conf)->acl_cache_map = NULL; |
| 19 | + (*conf)->acl_cache_mtx = NULL; // No mutex allocated when cache_ttl is 0 |
| 20 | + |
| 21 | + (*conf)->auth_req.enable = false; |
| 22 | + (*conf)->auth_req.url = NULL; |
| 23 | + (*conf)->auth_req.method = NULL; |
12 | 24 | (*conf)->auth_req.header_count = 0; |
| 25 | + (*conf)->auth_req.headers = NULL; |
| 26 | + (*conf)->auth_req.param_count = 0; |
| 27 | + (*conf)->auth_req.params = NULL; |
| 28 | + |
| 29 | + (*conf)->super_req.enable = false; |
| 30 | + (*conf)->super_req.url = NULL; |
| 31 | + (*conf)->super_req.method = NULL; |
| 32 | + (*conf)->super_req.header_count = 0; |
| 33 | + (*conf)->super_req.headers = NULL; |
| 34 | + (*conf)->super_req.param_count = 0; |
| 35 | + (*conf)->super_req.params = NULL; |
| 36 | + |
| 37 | + (*conf)->acl_req.enable = false; |
| 38 | + (*conf)->acl_req.url = NULL; |
| 39 | + (*conf)->acl_req.method = NULL; |
| 40 | + (*conf)->acl_req.header_count = 0; |
| 41 | + (*conf)->acl_req.headers = NULL; |
| 42 | + (*conf)->acl_req.param_count = 0; |
| 43 | + (*conf)->acl_req.params = NULL; |
13 | 44 |
|
14 | 45 | return; |
15 | 46 | } |
|
0 commit comments