From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A77C11FAF5 for ; Wed, 16 Nov 2022 09:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1668590807; bh=SnWH8VMysrFDcjaJlU/YAkFT540kipKYveS8kMu94As=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GwdPdAvfW2UGTto1soqJudirUwT00jBhfaVRI2uyKWJuWMHEXMOW/hphsefeeZbXZ zpWx2ZVyg5DhnE3fsOFUjIYIOiiJ9hZGZjLQNHPnVXpt5kMsNyGOhrI70QncV2cD6e 8BAheu8W9ePVWYujnwB2sp8S0f3bbgwEIQmiWvjw= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 6/6] location_name: handle malloc failure on backtrace_symbols(3) Date: Wed, 16 Nov 2022 09:26:46 +0000 Message-Id: <20221116092646.19919-7-e@80x24.org> In-Reply-To: <20221116092646.19919-1-e@80x24.org> References: <20221116092646.19919-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: backtrace_symbols(3) may fail due to malloc failures, so we must account for it and return `undef' in that case. --- Mwrap.xs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Mwrap.xs b/Mwrap.xs index c8a4568..b515894 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -19,6 +19,12 @@ static SV *location_string(struct src_loc *l) if (loc_is_addr(l)) { char **s = backtrace_symbols((void *)l->k, 1); + if (!s) { + fprintf(stderr, "backtrace_symbols => NULL: %s\n", + strerror(errno)); + return &PL_sv_undef; + } + ret = newSVpvn(s[0], strlen(s[0])); free(s); } else {