Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22819 Fix memory leak during error in mlbe.cpp #3078

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

FrankYFTang
Copy link
Contributor

Checklist
  • Required: Issue filed: https://unicode-org.atlassian.net/browse/ICU-22819
  • Required: The PR title must be prefixed with a JIRA Issue number.
  • Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
  • Required: Each commit message must be prefixed with a JIRA Issue number.
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

@FrankYFTang
Copy link
Contributor Author

@tushuhei

@FrankYFTang FrankYFTang changed the title ICU-22819 Fix memory leak during error ICU-22819 Fix memory leak during error in mlbe.cpp Aug 1, 2024
if (idx + 4 < codePointLength) {
indexList[idx + 6] = numCodeUnits;
numCodeUnits += U16_LENGTH(inString.char32At(indexList[idx + 6]));
}
}
}
uprv_free(indexList);
Copy link
Contributor

Choose a reason for hiding this comment

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

You could change indexList to be a LocalMemory<int32_t>. Get rid of the error prone naked pointer and explicit free() altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

I second that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PTAL

@FrankYFTang FrankYFTang force-pushed the ICU-22819-mlbeMemoryLeak branch from 5cbd66f to 61fa9cf Compare August 2, 2024 09:19
@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4c/source/common/mlbe.cpp is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@FrankYFTang FrankYFTang requested a review from aheninger August 2, 2024 09:19
if (idx + 4 < codePointLength) {
indexList[idx + 6] = numCodeUnits;
numCodeUnits += U16_LENGTH(inString.char32At(indexList[idx + 6]));
}
}
}
uprv_free(indexList);
Copy link
Contributor

Choose a reason for hiding this comment

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

I second that...

@roubert roubert removed their request for review August 5, 2024 13:11
@FrankYFTang FrankYFTang merged commit 2f5a46f into unicode-org:main Aug 5, 2024
99 checks passed
@FrankYFTang FrankYFTang deleted the ICU-22819-mlbeMemoryLeak branch August 5, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants