Skip to content

Commit e096660

Browse files
author
SendaoYan
committed
8345043: [ASAN] methodMatcher.cpp report reading from a region of size 0 [-Werror=stringop-overread]
Reviewed-by: kbarrett, dholmes
1 parent 1033385 commit e096660

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/hotspot/share/compiler/methodMatcher.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,22 @@ bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) con
219219

220220
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
221221
int match = MethodMatcher::Exact;
222+
size_t len = strlen(name);
222223
if (name[0] == '*') {
223-
if (strlen(name) == 1) {
224+
if (len == 1) {
224225
return MethodMatcher::Any;
225226
}
226227
match |= MethodMatcher::Suffix;
227-
memmove(name, name + 1, strlen(name + 1) + 1);
228+
memmove(name, name + 1, len); // Include terminating nul in move.
229+
len--;
228230
}
229231

230-
size_t len = strlen(name);
231232
if (len > 0 && name[len - 1] == '*') {
232233
match |= MethodMatcher::Prefix;
233234
name[--len] = '\0';
234235
}
235236

236-
if (strlen(name) == 0) {
237+
if (len == 0) {
237238
error_msg = "** Not a valid pattern";
238239
return MethodMatcher::Any;
239240
}

0 commit comments

Comments
 (0)