Skip to content

Commit

Permalink
Correct segmentation fault in rSOILWAT2
Browse files Browse the repository at this point in the history
- Move the rSOILWAT2 access to `outfile` to after the key is calculated (instead of the default value -1)
  • Loading branch information
N1ckP3rsl3y committed Dec 7, 2024
1 parent 4a2af22 commit 4b43a46
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/SW_Output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2936,17 +2936,6 @@ void SW_OUT_read(
goto closeFile;
}

// For now: rSOILWAT2's function `onGet_SW_OUT` requires that
// `OutDom->outfile[k]` is allocated here
#if defined(RSOILWAT)
OutDom->outfile[k] = Str_Dup(outfile, LogInfo);
if (LogInfo->stopRun) {
goto closeFile;
}
#else
outfile[0] = '\0';
#endif

first = sw_strtoi(firstStr, MyFileName, LogInfo);
if (LogInfo->stopRun) {
goto closeFile;
Expand All @@ -2965,6 +2954,17 @@ void SW_OUT_read(
goto closeFile;
}

// For now: rSOILWAT2's function `onGet_SW_OUT` requires that
// `OutDom->outfile[k]` is allocated here
#if defined(RSOILWAT)
OutDom->outfile[k] = Str_Dup(outfile, LogInfo);
if (LogInfo->stopRun) {
goto closeFile;
}
#else
outfile[0] = '\0';
#endif

// Fill information into `sw->Output[k]`
msg_type = SW_OUT_read_onekey(
OutDom,
Expand Down

0 comments on commit 4b43a46

Please sign in to comment.