-
Notifications
You must be signed in to change notification settings - Fork 0
Release v0.2.2 #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,13 +130,10 @@ end | |
| macro buffer(specs, ex) | ||
| buf, T, len = _parse_specs(specs) | ||
| quote | ||
| let $(esc(buf)) = MAllocBuffer{$(esc(T))}($(esc(len))) | ||
| try | ||
| $(esc(ex)) | ||
| finally | ||
| free!($(esc(buf))) | ||
| end | ||
| end | ||
| $(esc(buf)) = MAllocBuffer{$(esc(T))}($(esc(len))) | ||
| $(esc(ex)) | ||
| free!($(esc(buf))) | ||
| $(esc(buf)) = nothing | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -150,15 +147,13 @@ macro buffer(specs, specs2, ex) | |
| buf, T, len = _parse_specs(specs) | ||
| buf2, T2, len2 = _parse_specs(specs2) | ||
| quote | ||
| let $(esc(buf)) = MAllocBuffer{$(esc(T))}($(esc(len))), | ||
| $(esc(buf2)) = MAllocBuffer{$(esc(T2))}($(esc(len2))) | ||
| try | ||
| $(esc(ex)) | ||
| finally | ||
| free!($(esc(buf2))) | ||
| free!($(esc(buf))) | ||
| end | ||
| end | ||
| $(esc(buf)) = MAllocBuffer{$(esc(T))}($(esc(len))) | ||
| $(esc(buf2)) = MAllocBuffer{$(esc(T2))}($(esc(len2))) | ||
| $(esc(ex)) | ||
| free!($(esc(buf2))) | ||
| free!($(esc(buf))) | ||
| $(esc(buf2)) = nothing | ||
| $(esc(buf)) = nothing | ||
|
Comment on lines
+150
to
+156
|
||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the
let/try...finallystructure here meansfree!is no longer guaranteed to run ifexthrows, soMAllocBuffer's underlying memory will leak on exceptions (there is no finalizer onMAllocBuffer, andfree!is the only place that callsLibc.free). Please restore exception-safe cleanup (e.g., via atry...finallyor equivalent pattern that still fixes the scope issue) so that@buffertruly frees the buffer after use even on error.