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

Prevent crashing for "Unsupported image type" error #2317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mari-rs
Copy link

@mari-rs mari-rs commented Dec 2, 2023

Hi,

I hope this message finds all of you well. I have encountered an issue where the "Unsupported image type" error was being thrown in the setSource function of the canvas library. After investigating, I found out that this error was causing unexpected crashes in certain scenarios.

In my case these certain scenarios were pretty interesting. I have not been interacting directly with the library, randomly, my code crashed because of this error. My motivation to fix this error is a more robust code base, because in my case, my application should not crash in no matter what case.

To address this issue, I have added a try-catch block to the setSource function in the lib/image.js file. This should prevent unexpected crashes hopefully and ensures that the application can gracefully handle cases where the image type is not supported.

I have added the following code to address this issue.

function setSource (img, src, origSrc) {
 try {
   SetSource.call(img, src)
   img._originalSource = origSrc
 } catch (err) {
   img._originalSource = null
   throw err
 }
}

I will already say thank you for reviewing my pull requests! let me know if it's possible to apply these changes.

sincerely Rosie!

adding try and catch block to lib/image.js
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.

None yet

1 participant