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

Infinite loop when first word is longer than line #309

Merged
merged 1 commit into from Sep 12, 2014

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Sep 12, 2014

It's possible to trigger an infinite loop if the first words in a string are too long for the line. We end up trying to use @spaceLeft before it's initialized, which then causes us to break off too big a piece of the word, which causes @spaceLeft to go negative, which makes this loop run forever:

while w > @spaceLeft
  w = @wordWidth word.slice(0, --l)

To see the bug try running:

doc.text("COMPRESSION STOCKINGS KNEE-HIGH", {width: 64});

devongovett added a commit that referenced this pull request Sep 12, 2014
Infinite loop when first word is longer than line
@devongovett devongovett merged commit 4f2f0e6 into foliojs:master Sep 12, 2014
@devongovett
Copy link
Member

Looks like #305. Thanks for the fix.

@devongovett devongovett mentioned this pull request Sep 12, 2014
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

2 participants