-
-
Notifications
You must be signed in to change notification settings - Fork 41
Preserve caller-owned invite target streams #758
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 |
|---|---|---|
|
|
@@ -3899,13 +3899,16 @@ internal async Task<DiscordInvite> CreateChannelInviteAsync(ulong channelId, int | |
| var ret = DiscordJson.DeserializeObject<DiscordInvite>(res.Response, this.Discord); | ||
| ret.Discord = this.Discord; | ||
|
|
||
| try | ||
| { | ||
| targetUsersCsv?.Stream.Dispose(); | ||
| } | ||
| catch | ||
| if (targetUsersCsv is not null && targetUsersCsv.ResetPositionTo is null) | ||
| { | ||
| // ignore | ||
| try | ||
| { | ||
| targetUsersCsv.Stream.Dispose(); | ||
| } | ||
| catch | ||
| { | ||
| // ignore | ||
| } | ||
| } | ||
|
|
||
| return ret; | ||
|
|
@@ -5152,13 +5155,16 @@ internal async Task UpdateInviteTargetUsersAsync(string inviteCode, Stream? targ | |
|
|
||
| if (targetUsersCsv.ResetPositionTo is not null) | ||
| targetUsersCsv.Stream.Position = targetUsersCsv.ResetPositionTo.Value; | ||
| try | ||
| { | ||
| targetUsersCsv.Stream.Dispose(); | ||
| } | ||
| catch | ||
| else if (targetUsersCsv is not null) | ||
| { | ||
| // ignore | ||
| try | ||
| { | ||
|
Comment on lines
+5158
to
+5161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This disposal path still closes user-owned streams that are not seekable because Useful? React with 👍 / 👎. |
||
| targetUsersCsv.Stream.Dispose(); | ||
| } | ||
| catch | ||
| { | ||
| // ignore | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This disposal guard treats
ResetPositionTo == nullas “internally owned,” but user-supplied streams that are not seekable also produceResetPositionTo == nullinCreateTargetUsersFile. In that case, the caller’s stream will still be disposed here, which contradicts the intent of preserving caller ownership and can still triggerObjectDisposedExceptionif the caller reuses the stream afterCreateChannelInviteAsync. Consider tracking ownership separately (e.g., a flag from thetargetUsersFileparameter) rather than relying onResetPositionToalone.Useful? React with 👍 / 👎.