diff options
author | markj <markj@FreeBSD.org> | 2017-03-10 18:54:48 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2017-03-10 18:54:48 +0000 |
commit | 9a84a0784c84560cfaa7de28b50a582122416246 (patch) | |
tree | 7c5e80e256362455ccf0cf00b88c8c55b7ab3533 /cddl/contrib/opensolaris/lib/libdtrace/common | |
parent | 9b0c2e7104a8484ee31ce973fdcad8f2fb066d46 (diff) | |
download | FreeBSD-src-9a84a0784c84560cfaa7de28b50a582122416246.zip FreeBSD-src-9a84a0784c84560cfaa7de28b50a582122416246.tar.gz |
MFC r314153, r314154:
Fix some memory leaks in CDDL code.
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace/common')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c | 8 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index ac0524b..653f2b2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -933,9 +933,11 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) * reallocate it. We normally won't need to do this * because providers aren't being loaded all the time. */ - if ((p = realloc(p_providers,len)) == NULL) + if ((p = realloc(p_providers,len)) == NULL) { + free(p_providers); /* How do we report errors here? */ return; + } p_providers = p; } else break; @@ -1150,8 +1152,10 @@ dt_vopen(int version, int flags, int *errp, (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC); alloc: - if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) + if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) { + dt_provmod_destroy(&provmod); return (set_open_errno(dtp, errp, EDT_NOMEM)); + } bzero(dtp, sizeof (dtrace_hdl_t)); dtp->dt_oflags = flags; diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c index 21669c8..a735b66 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c @@ -256,8 +256,10 @@ dt_strtab_insert(dt_strtab_t *sp, const char *str) * Now copy the string data into our buffer list, and then update * the global counts of strings and bytes. Return str's byte offset. */ - if (dt_strtab_copyin(sp, str, len + 1) == -1) + if (dt_strtab_copyin(sp, str, len + 1) == -1) { + free(hp); return (-1L); + } sp->str_nstrs++; sp->str_size += len + 1; |