Skip to content
Permalink
Browse files
8275517: Off-by-one error in allocation
Reviewed-by: tschatzl
  • Loading branch information
Markus Grönlund committed Oct 19, 2021
1 parent 8a3e0a1 commit 99bf7dd8ddac1b5870534af50c97bec554004248
Showing 1 changed file with 2 additions and 4 deletions.
@@ -46,7 +46,7 @@ static const char* allocate(oop string) {
const typeArrayOop value = java_lang_String::value(string);
if (value != nullptr) {
const int length = java_lang_String::utf8_length(string, value);
str = NEW_C_HEAP_ARRAY(char, length, mtServiceability);
str = NEW_C_HEAP_ARRAY(char, length + 1, mtServiceability);
java_lang_String::as_utf8_string(string, value, str, length + 1);
}
return str;
@@ -94,9 +94,7 @@ FinalizerEntry::FinalizerEntry(const InstanceKlass* ik) :
_total_finalizers_run(0) {}

FinalizerEntry::~FinalizerEntry() {
if (_codesource != nullptr) {
FREE_C_HEAP_ARRAY(char, _codesource);
}
FREE_C_HEAP_ARRAY(char, _codesource);
}

const InstanceKlass* FinalizerEntry::klass() const {

1 comment on commit 99bf7dd

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 99bf7dd Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.