Skip to content

Commit da70482

Browse files
committed
Prevent substring call if the result would be an empty string
1 parent db9c463 commit da70482

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ public static String replace(
128128
return template;
129129
}
130130
else {
131-
String beforePlaceholder = template.substring( 0, loc );
131+
String beforePlaceholder = "";
132+
if (loc > 0) {
133+
beforePlaceholder = template.substring(0, loc);
134+
}
132135
String afterPlaceholder = template.substring( loc + placeholder.length() );
133136
return replace(
134137
beforePlaceholder,

0 commit comments

Comments
 (0)