Skip to content

fix: prevent crash when endPDF is called twice#475

Open
SergeySD wants to merge 1 commit intojulianhille:developfrom
SergeySD:fix/prevent-double-endPDF
Open

fix: prevent crash when endPDF is called twice#475
SergeySD wants to merge 1 commit intojulianhille:developfrom
SergeySD:fix/prevent-double-endPDF

Conversation

@SergeySD
Copy link
Copy Markdown

Summary

  • Add guard to prevent calling endPDF() multiple times on a Recipe instance
  • Throws a descriptive error instead of causing a segmentation fault
  • Add test to verify the behavior

Test plan

  • Run npm test - all 172 tests pass
  • New test tests/recipe/endPDF-twice.js verifies error is thrown on second call

Add guard to throw a descriptive error instead of causing a
segmentation fault when endPDF is called multiple times.
Comment thread lib/Recipe.js
Comment on lines +221 to +224
if (this._pdfEnded) {
throw new Error("endPDF has already been called");
}
this._pdfEnded = true;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

isnt this just a patch on a broken leg?? :>
like if it has a segmentation fault if this.writer.end is called this is just preventing for receipe this error and for no one else.

What i'm saying is i'm not sure if this is a proper fix will look into it. thank you very much for you pull request anyway.

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