diff --git a/ChangeLog b/ChangeLog index a9e90b1..d558da3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,8 @@ substituting. 11. Add check for NULL subject to POSIX regexec() function. +12. Add check for NULL replacement to pcre2_substitute(). + Version 10.39 29-October-2021 ----------------------------- diff --git a/src/pcre2_substitute.c b/src/pcre2_substitute.c index 7aefb60..3d55d88 100644 --- a/src/pcre2_substitute.c +++ b/src/pcre2_substitute.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2020 University of Cambridge + New API code Copyright (c) 2016-2021 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -261,9 +261,9 @@ if ((options & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) != 0) return PCRE2_ERROR_BADOPTION; /* Validate length and find the end of the replacement. */ -if (replacement == NULL && rlength > 0) return PCRE2_ERROR_NULL; -else if (rlength == PCRE2_ZERO_TERMINATED) - rlength = PRIV(strlen)(replacement); + +if (replacement == NULL) return PCRE2_ERROR_NULL; +if (rlength == PCRE2_ZERO_TERMINATED) rlength = PRIV(strlen)(replacement); repend = replacement + rlength; /* Check for using a match that has already happened. Note that the subject