c
c copied to clipboard
Memory Leak in kubeyaml_load_kubeconfig() in kubernetes/config/kube_config_yaml.c
Hi,
I found a memory leak when calling kubeyaml_load_kubeconfig()
kubeyaml_load_kubeconfig creates a yaml parser object before attempting to read the kubeconfig file.
If opening the kubeconfig file failed for some reason, the function returns(-1) without freeing up the memory allocated to parser.
snippet of the code in question where the leak occurs
/* Create the Parser object. */
yaml_parser_initialize(&parser);
/* Set a file input. */
FILE *input = NULL;
if (kubeconfig->fileName) {
input = fopen(kubeconfig->fileName, "rb");
if (!input) {
fprintf(stderr, "%s: Cannot open the file %s.[%s]\n", fname, kubeconfig->fileName, strerror(errno));
return -1; <<<<<
}
} else {
fprintf(stderr, "%s: The kubeconf file name needs be set by kubeconfig->fileName .\n", fname);
return -1; <<<<<
}
Thank you for reporting this issue.
Will fix it later.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale
- Mark this issue or PR as rotten with
/lifecycle rotten
- Close this issue or PR with
/close
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
Any update on this? I experienced the same.
I'll find a cycle to fix it in a few days. Fix PRs from anyone are also welcome.