< prev index next >

src/hotspot/share/oops/annotations.cpp

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -39,11 +39,13 @@
  
  // helper
  void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) {
    if (p != nullptr) {
      for (int i = 0; i < p->length(); i++) {
-       MetadataFactory::free_array<u1>(loader_data, p->at(i));
+       if (p->at(i) != nullptr) {
+         MetadataFactory::free_array<u1>(loader_data, p->at(i));
+       }
      }
      MetadataFactory::free_array<AnnotationArray*>(loader_data, p);
    }
  }
  
< prev index next >