Skip to content

Conversation

@andrew-platt
Copy link
Collaborator

@andrew-platt andrew-platt commented May 15, 2025

Ready to merge

Feature or improvement description
PR #2792 fixed a parsing issue with restarts in the cpp interface. That PR will be included in 4.1, but since we are doing a 4.0.5 release, we might as well backport it.

Related issue, if one exists
See #2792 for details.
Also includes #2793 (fix possible memory leak)

Impacted areas of the software
CPP interface restarts only

Test results, if applicable
None.

@andrew-platt andrew-platt added this to the 4.0.5 milestone May 15, 2025
@andrew-platt andrew-platt self-assigned this May 15, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports a fix to the parsing of the restart file name in the CPP interface from PR #2792.

  • Introduces dynamic allocation for out_file_root using malloc.
  • Adds error checking after reading the attribute and ensures proper string termination.
Comments suppressed due to low confidence (1)

glue-codes/openfast-cpp/src/OpenFAST.cpp:106

  • Dynamically allocated memory in tmpOutFileRoot is not freed after assignment, which may lead to a memory leak. Consider using a smart pointer or explicitly calling free(tmpOutFileRoot) after the assignment.
turbineData[iTurbLoc].outFileRoot.assign(tmpOutFileRoot);

@andrew-platt andrew-platt changed the title Fix restart parsing of file name (backport of #2792 Fix restart parsing of file name (backport of #2792 and #2793) May 15, 2025
@andrew-platt andrew-platt requested a review from Copilot May 15, 2025 21:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports fixes for restart file name parsing and a potential memory leak in the C++ interface.

  • Replace fixed-size char array with dynamic allocation for retrieving "out_file_root".
  • Ensure proper error checking and memory deallocation for dynamically allocated buffer.

@andrew-platt
Copy link
Collaborator Author

Based on suggestion from @copilot, backported the memory leak fix of #2793 as well.

@andrew-platt andrew-platt merged commit 2380d81 into OpenFAST:rc-4.0.5 May 15, 2025
65 of 66 checks passed
@andrew-platt andrew-platt deleted the bp/Backport_2792_cppRestartParse branch May 23, 2025 19:57
@andrew-platt andrew-platt mentioned this pull request Jun 11, 2025
35 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants