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

Fix uninitialized memory in ModelicaInternal_readLine, ModelicaStrings_scanIdentifier and ModelicaStrings_scanString #3092

Merged
merged 1 commit into from
Aug 14, 2019

Conversation

beutlich
Copy link
Member

@beutlich beutlich added bug Critical/severe issue L: C-Sources Issue addresses Modelica/Resources/C-Sources labels Aug 14, 2019
@beutlich beutlich added this to the MSL4.0.0 milestone Aug 14, 2019
@beutlich beutlich self-assigned this Aug 14, 2019
@beutlich beutlich added the specification Issue (also) addresses the Modelica language specification label Aug 14, 2019
@henrikt-ma
Copy link
Contributor

Why don't we wait and see whether ModelicaAllocateString is supposed to terminate these strings?

Copy link
Member

@sjoelund sjoelund left a comment

Choose a reason for hiding this comment

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

Safe thing to do regardless of what the specification says or will say (the library is also backwards compatible with older versions of MSL)

@beutlich
Copy link
Member Author

beutlich commented Aug 14, 2019

Why don't we wait and see whether ModelicaAllocateString is supposed to terminate these strings?

Because I consider it a bug. See #3004 for a similar issue fixed recently.

Copy link
Contributor

@henrikt-ma henrikt-ma left a comment

Choose a reason for hiding this comment

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

I agree with @sjoelund point that the library should also be compatible with external code written for older MLS versions when the terminating null wasn't granted.

@beutlich beutlich removed the request for review from HansOlsson August 14, 2019 12:43
@beutlich beutlich merged commit d020a0b into modelica:master Aug 14, 2019
@beutlich beutlich deleted the fix-mem branch August 14, 2019 12:44
@beutlich beutlich changed the title Fix uninitialized memory Fix uninitialized memory in ModelicaInternal_readLine, ModelicaStrings_scanIdentifier and ModelicaStrings_scanString Aug 14, 2019
@HansOlsson
Copy link
Contributor

Note: I was going to comment on this - seems I was too late.

The most obvious solution would be to just return ""; as the specification only states that non-literal return strings must be allocated with ModelicaAllocateString.

@henrikt-ma
Copy link
Contributor

The most obvious solution would be to just return ""; as the specification only states that non-literal return strings must be allocated with ModelicaAllocateString.

Right, but in that case I would suggest to also make sure that we have test models that take these code paths, so that implementations really become aware that they must do the tedious analysis of what kind of pointer that is being returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Critical/severe issue L: C-Sources Issue addresses Modelica/Resources/C-Sources specification Issue (also) addresses the Modelica language specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants