dymosoftware / dymo-connect-framework

DYMO Connect Framework for Javascript.
Other
87 stars 54 forks source link

Multiline text-object causes freeze/crash #26

Open mbmleone opened 2 years ago

mbmleone commented 2 years ago

Today we found a serious issue with Dymo Connect templates. They can cause a freeze with eventually a crash.

This happens in the following situation:

What happens is this:

  1. First the website freeze and makes it impossible to do anything.
  2. Then after a long time it resumes and shows this error in console:
    Uncaught InternalError: allocation size overflow
    _getAddressObjectText
  3. Nothing is printed by the Dymo printer.

Can this please be investigated and fixed? Thanks!

giuliodamato commented 2 years ago

Hi @mbmleone, I found the bug and fixed it 😂

The freeze is originated by a nested for loop that tragically overwrites the control variable of its parent 🤦‍♂️

https://github.com/dymosoftware/dymo-connect-framework/blob/1bf94721c5c9dcc74a13bb4f984ac488381942e4/dymo.connect.framework.js#L10432

Changing the loop to this solves the problem:

for (gz = 0; gz < n.length; gz++)
{
  var i = dymo.xml.getElement(n[gz], "Text");
  o += dymo.xml.getElementText(i)
}

I'll release the fix in my repo tomorrow 😉

@dymosoftware: I really deserve some gadgets now 😂

giuliodamato commented 2 years ago

The fixed version is in my repo, please check it out and confirm us that it actually works. https://github.com/giuliodamato/dymo-connect-framework

The version in the repo also fixes issue #13.

mbmleone commented 2 years ago

Thanks for the fixed release. We just checked it and it indeed fixes the issue! Thanks again!

mbmleone commented 6 months ago

We just discovered this causes line breaks to disappear. Please make sure the line breaks are added inside the loop.