Skip to content

Commit 2f0918c

Browse files
devnexenbukka
authored andcommitted
Fix FPM socket clean up reallocation clang build warning
1 parent fc9fecb commit 2f0918c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sapi/fpm/fpm/fpm_sockets.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
6565
close(ls->sock);
6666
} else { /* on PARENT EXEC we want socket fds to be inherited through environment variable */
6767
char fd[32];
68+
char *tmpenv_value;
6869
sprintf(fd, "%d", ls->sock);
6970

7071
socket_set_buf = (i % FPM_ENV_SOCKET_SET_SIZE == 0 && i) ? 1 : 0;
71-
env_value = realloc(env_value, p + (p ? 1 : 0) + strlen(ls->key) + 1 + strlen(fd) + socket_set_buf + 1);
72+
tmpenv_value = realloc(env_value, p + (p ? 1 : 0) + strlen(ls->key) + 1 + strlen(fd) + socket_set_buf + 1);
73+
if (!tmpenv_value) {
74+
zlog(ZLOG_SYSERROR, "failure to inherit data on parent exec for socket `%s` due to memory allocation failure", ls->key);
75+
free(ls->key);
76+
break;
77+
}
78+
79+
env_value = tmpenv_value;
7280

7381
if (i % FPM_ENV_SOCKET_SET_SIZE == 0) {
7482
socket_set[socket_set_count] = p + socket_set_buf;

0 commit comments

Comments
 (0)