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

Memory allocation error in CombiTimeTable when given UTF16 LE file #3603

Closed
maltelenz opened this issue Jul 8, 2020 · 2 comments · Fixed by #3604
Closed

Memory allocation error in CombiTimeTable when given UTF16 LE file #3603

maltelenz opened this issue Jul 8, 2020 · 2 comments · Fixed by #3604
Assignees
Labels
enhancement New feature or enhancement L: C-Sources Issue addresses Modelica/Resources/C-Sources
Milestone

Comments

@maltelenz
Copy link
Contributor

If a CombiTimeTable is given a UTF16-LE encoded text file of sufficient length (pretty short) it fails with a Memory allocation error.

I realize the table format requires UTF-8 or ASCII, but a nicer failure mode for such an invalid file would be nice.

To reproduce, create a model with a single CombiTimeTable component pointing to the attached file, and attempt to simulate:

MadeUpTable.txt

The error seems to come from https://github.com/modelica/ModelicaStandardLibrary/blob/master/Modelica/Resources/C-Sources/ModelicaIO.c#L1039 after bugLen overflows to negative numbers.

@maltelenz maltelenz added enhancement New feature or enhancement L: C-Sources Issue addresses Modelica/Resources/C-Sources labels Jul 8, 2020
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Jul 8, 2020
@beutlich beutlich self-assigned this Jul 8, 2020
@beutlich beutlich added this to the MSL4.1.0 milestone Jul 8, 2020
@beutlich
Copy link
Member

beutlich commented Jul 9, 2020

@maltelenz Do you think there might be some requirement to support UTF-16 encoded text files?

@maltelenz
Copy link
Contributor Author

@beutlich I don't see a large need for it. My personal experience is that everyone is using UTF-8, and the description on https://en.wikipedia.org/wiki/UTF-16 seems to agree:

It is rarely used for files on Unix-like systems. As of May 2019, Microsoft seems to have reversed course and now supports and recommends using UTF-8.[2]

UTF-16 never gained popularity on the web, where it is used by under 0.01% (1 hundredth of 1 percent) of web pages,[3] and UTF-8 dominates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement L: C-Sources Issue addresses Modelica/Resources/C-Sources
Projects
None yet
2 participants