Skip to content

hurricane refinement uses .back() on possibly empty track #2982

@asalmgren

Description

@asalmgren

Location

  • Source/ERF_Tagging.cpp:856-862

Problem

ERF::HurricaneTracker() does:

  • FindInitialEye(...) only when time == 0.0
  • otherwise reads hurricane_eye_track_xy.back() with no emptiness check

If the vector is empty (e.g., restart, or tracker output not populated yet), this is undefined behavior and can cras
h.

Why this is a bug

The function assumes cross-module state was already populated, but does not enforce or validate that precondition.

Suggested patch

Guard access and fallback to FindInitialEye() when history is unavailable.

--- a/Source/ERF_Tagging.cpp
+++ b/Source/ERF_Tagging.cpp
@@
-    if (time==0.0) {
+    if (time==0.0 || hurricane_eye_track_xy.empty()) {
         is_found = FindInitialEye(levc, mf_cc_vel, velmag_threshold, eye_x, eye_y);
     } else {
         is_found = true;
         const auto& last = hurricane_eye_track_xy.back();
         eye_x = last[0];
         eye_y = last[1];
     }

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions