[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] libpoke: Use strndup instead of xstrndup
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 2/2] libpoke: Use strndup instead of xstrndup |
Date: |
Thu, 07 May 2020 11:21:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
@@ -572,7 +571,12 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_print_stmt)
if (*p != '%')
{
p = strchrnul (fmt, '%');
- PKL_AST_PRINT_STMT_PREFIX (print_stmt) = xstrndup (fmt, p - fmt);
+ PKL_AST_PRINT_STMT_PREFIX (print_stmt) = strndup (fmt, p - fmt);
+ if (!PKL_AST_PRINT_STMT_PREFIX (print_stmt))
+ {
+ PKL_TRANS_PAYLOAD->errors++;
+ PKL_ICE (PKL_AST_LOC (print_stmt), _("out of memory"));
+ }
}
You don't need to do errors++ for ICEs. That field is only used for
compilation errors.