[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] libpoke: Use strndup instead of xstrndup
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] libpoke: Use strndup instead of xstrndup |
Date: |
Wed, 06 May 2020 16:41:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
@@ -572,7 +571,14 @@ 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_ERROR (PKL_AST_LOC (print_stmt),
+ "out of memory");
+ PKL_TRANS_PAYLOAD->errors++;
+ PKL_PASS_ERROR;
+ }
}
That should be an ICE instead.
/* Process the format string. */
@@ -841,7 +847,14 @@ PKL_PHASE_BEGIN_HANDLER (pkl_trans1_ps_print_stmt)
if (*p != '\0' && *p != '%')
{
char *end = strchrnul (p, '%');
- PKL_AST_PRINT_STMT_ARG_SUFFIX (arg) = xstrndup (p, end - p);
+ PKL_AST_PRINT_STMT_ARG_SUFFIX (arg) = strndup (p, end - p);
+ if (!PKL_AST_PRINT_STMT_ARG_SUFFIX (arg))
+ {
+ PKL_ERROR (PKL_AST_LOC (print_stmt),
+ "out of memory");
+ PKL_TRANS_PAYLOAD->errors++;
+ PKL_PASS_ERROR;
+ }
p = end;
}
}
Likewise.