Skip to content

Commit 5068f26

Browse files
arcwolfsage
authored andcommitted
Avoid passing non-literal to format function
This avoids the following error, reported by Jitka Plesníková <[email protected]> in a test of RC1: op.c: In function 'Perl_ck_ftst': op.c:9754:58: error: format not a string literal and no format arguments [-Werror=format-security] Perl_warner(aTHX_ packWARN(WARN_SYNTAX), array_passed_to_stat); In addition, the string in question is now made const.
1 parent 19d6c38 commit 5068f26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

op.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ recursive, but it's recursive on basic blocks, not on tree nodes.
109109
#define CALL_RPEEP(o) PL_rpeepp(aTHX_ o)
110110
#define CALL_OPFREEHOOK(o) if (PL_opfreehook) PL_opfreehook(aTHX_ o)
111111

112-
static char array_passed_to_stat[] = "Array passed to stat will be coerced to a scalar";
112+
static const char array_passed_to_stat[] = "Array passed to stat will be coerced to a scalar";
113113

114114
/* Used to avoid recursion through the op tree in scalarvoid() and
115115
op_free()
@@ -9751,7 +9751,7 @@ Perl_ck_ftst(pTHX_ OP *o)
97519751
}
97529752
else {
97539753
/* diag_listed_as: Array passed to stat will be coerced to a scalar%s */
9754-
Perl_warner(aTHX_ packWARN(WARN_SYNTAX), array_passed_to_stat);
9754+
Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "%s", array_passed_to_stat);
97559755
}
97569756
}
97579757
scalar((OP *) kid);

0 commit comments

Comments
 (0)