From 22daf952dea7abe094ad6b3f5ceed107ce7524a0 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 30 Jun 2019 15:51:25 +0100 Subject: [PATCH] src: clang build warning fix fix UB with string concatenations. += operator makes things clearer for compiler's perspective. PR-URL: https://github.com/nodejs/node/pull/28480 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- src/node_metadata.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node_metadata.cc b/src/node_metadata.cc index 602115ad4f2590..8c787138b46b6f 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -34,8 +34,10 @@ std::string GetOpenSSLVersion() { // sample openssl version string format // for reference: "OpenSSL 1.1.0i 14 Aug 2018" char buf[128]; - const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1; - const int end = search(OPENSSL_VERSION_TEXT + start, start, ' '); + const char* etext = OPENSSL_VERSION_TEXT; + const int start = search(etext, 0, ' ') + 1; + etext += start; + const int end = search(etext, start, ' '); const int len = end - start; snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]); return std::string(buf);