Skip to content

Commit 0a81676

Browse files
committed
8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer
Reviewed-by: clanger, mdoerr, dholmes, syan, amitkumar
1 parent 08debd3 commit 0a81676

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/hotspot/share/logging/logDecorators.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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) {
100100
break;
101101
}
102102
tmp_decorators |= mask(d);
103-
token = comma_pos + 1;
103+
if (comma_pos != nullptr) {
104+
token = comma_pos + 1;
105+
}
104106
} while (comma_pos != nullptr);
105107
os::free(args_copy);
106108
if (result) {

src/hotspot/share/logging/logSelection.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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) {
151151
return LogSelection::Invalid;
152152
}
153153
tags[ntags++] = tag;
154-
cur_tag = plus_pos + 1;
154+
if (plus_pos != nullptr) {
155+
cur_tag = plus_pos + 1;
156+
}
155157
} while (plus_pos != nullptr);
156158

157159
for (size_t i = 0; i < ntags; i++) {

src/hotspot/share/logging/logSelectionList.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
6969
}
7070
char* copy = os::strdup_check_oom(str, mtLogging);
7171
// Split string on commas
72-
for (char *comma_pos = copy, *cur = copy; success && comma_pos != nullptr; cur = comma_pos + 1) {
72+
for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) {
7373
if (_nselections == MaxSelections) {
7474
if (errstream != nullptr) {
7575
errstream->print_cr("Can not have more than " SIZE_FORMAT " log selections in a single configuration.",
@@ -90,6 +90,10 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
9090
break;
9191
}
9292
_selections[_nselections++] = selection;
93+
94+
if (comma_pos == nullptr) {
95+
break;
96+
}
9397
}
9498

9599
os::free(copy);

0 commit comments

Comments
 (0)