[PATCH] lib: use delete[] to free buffer allocated using new[]

Jani Nikula jani at nikula.org
Sat Mar 4 09:38:41 PST 2017


Fix warning caught by clang:

lib/regexp-fields.cc:41:2: warning: 'delete' applied to a pointer that was allocated
      with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
        delete buffer;
        ^
              []
lib/regexp-fields.cc:37:17: note: allocated with 'new[]' here
        char *buffer = new char[len];
                       ^
---
 lib/regexp-fields.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 9873af803991..b41747502e1e 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -38,7 +38,7 @@ compile_regex (regex_t &regexp, const char *str)
 	std::string msg;
 	(void) regerror (err, &regexp, buffer, len);
 	msg.assign (buffer, len);
-	delete buffer;
+	delete[] buffer;
 
 	throw Xapian::QueryParserError (msg);
     }
-- 
2.11.0



More information about the notmuch mailing list