Skip to content

Commit b890d52

Browse files
committed
vlog_warning: plug a memory leak
Reported by Maiquel Paiva
1 parent 4b3a5e7 commit b890d52

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

plugins/sudoers/logging.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ vlog_warning(const struct sudoers_context *ctx, unsigned int flags,
702702
{
703703
struct eventlog evlog;
704704
const char *errstr = NULL;
705-
char *message;
705+
char *message = NULL;
706706
bool ret = true;
707707
int len, oldlocale;
708708
int evl_flags = 0;
@@ -795,6 +795,7 @@ vlog_warning(const struct sudoers_context *ctx, unsigned int flags,
795795
}
796796

797797
done:
798+
free(message);
798799
va_end(ap2);
799800
sudoers_setlocale(oldlocale, NULL);
800801

@@ -945,6 +946,7 @@ log_parse_error(const struct sudoers_context *ctx, const char *file,
945946
len = asprintf(&message, _("%s: %s"), file, errstr);
946947
}
947948
if (len != -1) {
949+
/* journal_parse_error() takes ownership of copy on success. */
948950
if (!journal_parse_error(message)) {
949951
free(message);
950952
ret = false;

0 commit comments

Comments
 (0)