From 45b777e4dc85c05cd4a186f4bdcae543c21aaf08 Mon Sep 17 00:00:00 2001 From: Michael Steed Date: Sat, 22 Aug 2015 19:35:56 -0600 Subject: [PATCH] fixes from review - Makefile.in: restore iwyu target - regex_replacer_t::replace_matches(): correct size passed to realloc() --- Makefile.in | 7 +++++++ src/builtin_string.cpp | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index d63e2d119..aa868fc78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -848,6 +848,13 @@ depend: ./config.status .PHONY: depend +# Include What You Use +iwyu: + # Requires the --keep-going flag as it always returns 1 + # Can't set MAKEFLAGS on a target-specific basic + $(MAKE) -k _iwyu CXX=include-what-you-use +_iwyu: clean $(PROGRAMS) +.PHONY: iwyu _iwyu # # Cleanup targets diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index bebdbb5ee..99336e32c 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -460,12 +460,11 @@ static const wchar_t *pcre2_strerror(int err_code) struct compiled_regex_t { - const wchar_t *argv0; pcre2_code *code; pcre2_match_data *match; - compiled_regex_t(const wchar_t *argv0_, const wchar_t *pattern, bool ignore_case) - : argv0(argv0_), code(0), match(0) + compiled_regex_t(const wchar_t *argv0, const wchar_t *pattern, bool ignore_case) + : code(0), match(0) { // Disable some sequences that can lead to security problems uint32_t options = PCRE2_NEVER_UTF; @@ -885,7 +884,7 @@ public: { if (outlen < MAX_REPLACE_SIZE) { - outlen = std::max(2 * outlen, MAX_REPLACE_SIZE); + outlen = std::min(2 * outlen, MAX_REPLACE_SIZE); output = (wchar_t *)realloc(output, sizeof(wchar_t) * outlen); if (output == 0) {