Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: fix ns leak in parse_join_ns
coverity CID 389192: 550static int parse_join_ns(const char *ptr) 551{ ... 553 char *ns; 554 1. alloc_fn: Storage is returned from allocation function strdup. 2. var_assign: Assigning: ___p = storage returned from strdup(ptr). 3. Condition !___p, taking false branch. 4. leaked_storage: Variable ___p going out of scope leaks the storage it points to. 5. var_assign: Assigning: ns = ({...; ___p;}). 555 ns = xstrdup(ptr); 6. Condition ns == NULL, taking false branch. 556 if (ns == NULL) 557 return -1; 558 7. noescape: Resource ns is not freed or pointed-to in strchr. 559 aux = strchr(ns, ':'); 8. Condition aux == NULL, taking true branch. 560 if (aux == NULL) CID 389192 (#1 of 1): Resource leak (RESOURCE_LEAK)9. leaked_storage: Variable ns going out of scope leaks the storage it points to. 561 return -1; We should free ns string after we finish it's use in parse_join_ns, easiest way to do it is to use cleanup_free attribute. Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
- Loading branch information