Skip to content

Commit fd735fc

Browse files
Fix Potential Handler Leaks #1
Add pclose before function out
1 parent 35d313f commit fd735fc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kubernetes/config/exec_provider.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ int kube_exec_and_get_result(ExecCredential_t * exec_credential, const kubeconfi
7575
result_string = calloc(1, KUBECONFIG_EXEC_RESULT_BUFFER_SIZE);
7676
if (!result_string) {
7777
fprintf(stderr, "%s: Cannot allocate memory for command result.[%s]\n", fname, strerror(errno));
78+
#ifndef _WIN32
79+
pclose(fp);
80+
#else
81+
_pclose(fp);
82+
#endif
7883
return -1;
7984
}
8085
int result_string_remaining_size = KUBECONFIG_EXEC_RESULT_BUFFER_SIZE - 1;
@@ -85,6 +90,11 @@ int kube_exec_and_get_result(ExecCredential_t * exec_credential, const kubeconfi
8590
if (result_string_remaining_size <= 0) {
8691
fprintf(stderr, "%s: The buffer for exec result is not sufficient.\n", fname);
8792
rc = -1;
93+
#ifndef _WIN32
94+
pclose(fp);
95+
#else
96+
_pclose(fp);
97+
#endif
8898
goto end;
8999
}
90100
strncat(result_string, string_buf, strlen(string_buf));

0 commit comments

Comments
 (0)