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

Fix panic if feedback_array.size == 0 #1

Closed
wants to merge 1 commit into from

Conversation

kumattau
Copy link

@kumattau kumattau commented May 11, 2024

@wez

This PR fixes the following panic if feedback_array.size == 0.
I encountered at running wezterm on X11 in WSLg.

related to: wez/wezterm#2056

unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

@wez wez closed this in 358e226 May 11, 2024
wez added a commit to wez/wezterm that referenced this pull request May 11, 2024
@wez
Copy link
Owner

wez commented May 11, 2024

Ah, thanks! I pushed a slightly different version of this that applies to each from_raw_parts call, and updated wezterm main to reference the result.

@kumattau
Copy link
Author

kumattau commented May 11, 2024

@wez

Thank you for update.

358e226 returns empty array if ptr.is_null(), but I think it is better to return empty array if size == 0.

It is because ptr.is_null() && size != 0 means that something wrong occurs outside of xcb-imdkit-rs, so this case should panic and on the other side, !ptr.is_null() && size == 0 can be interpretted as empty array.

Of cause, I'm okay to keep the current ptr.is_null() check because it works without problem in usual case.

@kumattau kumattau deleted the feedback_array-zero branch May 11, 2024 15:07
saep pushed a commit to saep/wezterm that referenced this pull request Jul 14, 2024
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.

2 participants