Skip to content

Commit

Permalink
Merge pull request #5536 from bfaccini/changes_for_issue_5515_1
Browse files Browse the repository at this point in the history
core: handle ENOMEM gracefully during logging
  • Loading branch information
wlemkows authored Mar 8, 2023
2 parents 34b354f + 0a8add6 commit 9b201f7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/out.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2014-2021, Intel Corporation */
/* Copyright 2014-2023, Intel Corporation */

/*
* out.c -- support for logging, tracing, and assertion output
Expand Down Expand Up @@ -91,7 +91,7 @@ Last_errormsg_get(void)
if (errormsg == NULL) {
errormsg = malloc(sizeof(struct errormsg));
if (errormsg == NULL)
FATAL("!malloc");
return NULL;
/* make sure it contains empty string initially */
errormsg->msg[0] = '\0';
int ret = os_tls_set(Last_errormsg_key, errormsg);
Expand Down Expand Up @@ -425,6 +425,11 @@ out_error(const char *file, int line, const char *func,

char *errormsg = (char *)out_get_errormsg();

if (errormsg == NULL) {
Print("There's no memory to properly format error strings.");
return;
}

if (fmt) {
if (*fmt == '!') {
sep = ": ";
Expand Down

0 comments on commit 9b201f7

Please sign in to comment.