mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Fix memory leak in helper.c
Thanks to Xu Mingjie <xumingjie1995@outlook.com> for spotting this.
This commit is contained in:
10
src/helper.c
10
src/helper.c
@@ -80,6 +80,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int i, pipefd[2];
|
int i, pipefd[2];
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
|
unsigned char *alloc_buff = NULL;
|
||||||
|
|
||||||
/* create the pipe through which the main program sends us commands,
|
/* create the pipe through which the main program sends us commands,
|
||||||
then fork our process. */
|
then fork our process. */
|
||||||
@@ -186,11 +187,16 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
struct script_data data;
|
struct script_data data;
|
||||||
char *p, *action_str, *hostname = NULL, *domain = NULL;
|
char *p, *action_str, *hostname = NULL, *domain = NULL;
|
||||||
unsigned char *buf = (unsigned char *)daemon->namebuff;
|
unsigned char *buf = (unsigned char *)daemon->namebuff;
|
||||||
unsigned char *end, *extradata, *alloc_buff = NULL;
|
unsigned char *end, *extradata;
|
||||||
int is6, err = 0;
|
int is6, err = 0;
|
||||||
int pipeout[2];
|
int pipeout[2];
|
||||||
|
|
||||||
free(alloc_buff);
|
/* Free rarely-allocated memory from previous iteration. */
|
||||||
|
if (alloc_buff)
|
||||||
|
{
|
||||||
|
free(alloc_buff);
|
||||||
|
alloc_buff = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* we read zero bytes when pipe closed: this is our signal to exit */
|
/* we read zero bytes when pipe closed: this is our signal to exit */
|
||||||
if (!read_write(pipefd[0], (unsigned char *)&data, sizeof(data), 1))
|
if (!read_write(pipefd[0], (unsigned char *)&data, sizeof(data), 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user