Skip to content

Commit 22daf95

Browse files
devnexentargos
authored andcommitted
src: clang build warning fix
fix UB with string concatenations. += operator makes things clearer for compiler's perspective. PR-URL: #28480 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 871a60c commit 22daf95

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node_metadata.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ std::string GetOpenSSLVersion() {
3434
// sample openssl version string format
3535
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
3636
char buf[128];
37-
const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1;
38-
const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ');
37+
const char* etext = OPENSSL_VERSION_TEXT;
38+
const int start = search(etext, 0, ' ') + 1;
39+
etext += start;
40+
const int end = search(etext, start, ' ');
3941
const int len = end - start;
4042
snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
4143
return std::string(buf);

0 commit comments

Comments
 (0)