From d25d806be8efc1411dfd2c557be44a548876ce35 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Thu, 2 Jan 2025 13:56:37 +0100 Subject: [PATCH 1/3] JDK-8346881 --- src/hotspot/share/logging/logSelection.cpp | 6 ++++-- src/hotspot/share/logging/logSelectionList.cpp | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/logging/logSelection.cpp b/src/hotspot/share/logging/logSelection.cpp index 99ecc9f87f272..f5a0ab1bf533a 100644 --- a/src/hotspot/share/logging/logSelection.cpp +++ b/src/hotspot/share/logging/logSelection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,9 @@ static LogSelection parse_internal(char *str, outputStream* errstream) { return LogSelection::Invalid; } tags[ntags++] = tag; - cur_tag = plus_pos + 1; + if (plus_pos != nullptr) { + cur_tag = plus_pos + 1; + } } while (plus_pos != nullptr); for (size_t i = 0; i < ntags; i++) { diff --git a/src/hotspot/share/logging/logSelectionList.cpp b/src/hotspot/share/logging/logSelectionList.cpp index ac63f20512c2a..5c9f86cb80b18 100644 --- a/src/hotspot/share/logging/logSelectionList.cpp +++ b/src/hotspot/share/logging/logSelectionList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,6 +90,10 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) { break; } _selections[_nselections++] = selection; + + if (comma_pos == nullptr) { + break; + } } os::free(copy); From 9fd0a5a39941f8f00765e423cfb0bd91842b2004 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Thu, 2 Jan 2025 15:23:40 +0100 Subject: [PATCH 2/3] for loop check has been moved --- src/hotspot/share/logging/logSelectionList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/logging/logSelectionList.cpp b/src/hotspot/share/logging/logSelectionList.cpp index 5c9f86cb80b18..d7e5981aa00c8 100644 --- a/src/hotspot/share/logging/logSelectionList.cpp +++ b/src/hotspot/share/logging/logSelectionList.cpp @@ -69,7 +69,7 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) { } char* copy = os::strdup_check_oom(str, mtLogging); // Split string on commas - for (char *comma_pos = copy, *cur = copy; success && comma_pos != nullptr; cur = comma_pos + 1) { + for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) { if (_nselections == MaxSelections) { if (errstream != nullptr) { errstream->print_cr("Can not have more than " SIZE_FORMAT " log selections in a single configuration.", From e67c271e737be58f300cd472de63fffd397e9144 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Fri, 3 Jan 2025 09:51:52 +0100 Subject: [PATCH 3/3] address iteration in logDecorators.cpp --- src/hotspot/share/logging/logDecorators.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/logging/logDecorators.cpp b/src/hotspot/share/logging/logDecorators.cpp index 6c06bd4571627..019c2fcb36ca5 100644 --- a/src/hotspot/share/logging/logDecorators.cpp +++ b/src/hotspot/share/logging/logDecorators.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,7 +100,9 @@ bool LogDecorators::parse(const char* decorator_args, outputStream* errstream) { break; } tmp_decorators |= mask(d); - token = comma_pos + 1; + if (comma_pos != nullptr) { + token = comma_pos + 1; + } } while (comma_pos != nullptr); os::free(args_copy); if (result) {