diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index 39118e38f5c7f..c3c6476294200 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -287,10 +287,12 @@ class GrowableArrayView : public GrowableArrayBase { } void sort(int f(E*, E*)) { + if (_data == nullptr) return; qsort(_data, length(), sizeof(E), (_sort_Fn)f); } // sort by fixed-stride sub arrays: void sort(int f(E*, E*), int stride) { + if (_data == nullptr) return; qsort(_data, length() / stride, sizeof(E) * stride, (_sort_Fn)f); }