X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.c;h=4e6d930ed215c9f0ae0852236d7329b82d250777;hb=ca9279baf07d6843f58a31f1ce3ff7dc875faf1a;hp=9d6948e948a8da3f7d410509f2385418cff06067;hpb=953cdb4a8c192dad24419e2faad15e31948e48a6;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.c b/sv.c index 9d6948e..4e6d930 100644 --- a/sv.c +++ b/sv.c @@ -8431,25 +8431,6 @@ Perl_sv_vsetpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, maybe_tainted); } -/* my_strnchr(): private function for use in sv_vcatpvfn() - * - * Like strchr(), but allows to use strings that are not null-terminated. - * The string length must be given instead and it _must_ be correct, as - * the function does not stop searching when a '\0' is discovered. - * This would also allow to explicitly search for '\0' characters. - */ - -STATIC -const char * -S_my_strnchr(const char* s, int c, size_t n) -{ - if (s) - for (; n > 0; n--, s++) - if ((int)*s == c) - return s; - return NULL; -} - /* private function for use in sv_vcatpvfn via the EXPECT_NUMBER macro */ STATIC I32 @@ -9348,11 +9329,9 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV p = SvEND(sv); *p = '\0'; } - /* Don't use strchr() here, because eptr does not necessarily point */ - /* to a null-terminated string. E.g. with the format "%-10c", eptr */ - /* points to c (a single char on the stack), which makes strchr() */ - /* run amok over the stack until it eventually hits '\n' or '\0'. */ - if (left && ckWARN(WARN_PRINTF) && my_strnchr(eptr, '\n', elen) && + /* Use memchr() instead of strchr(), as eptr is not guaranteed */ + /* to point to a null-terminated string. */ + if (left && ckWARN(WARN_PRINTF) && memchr(eptr, '\n', elen) && (PL_op->op_type == OP_PRTF || PL_op->op_type == OP_SPRINTF)) Perl_warner(aTHX_ packWARN(WARN_PRINTF), "Newline in left-justified string for %sprintf",