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

_mxml_vstrdupf bug on Windows #245

Closed
ironxu opened this issue Feb 10, 2019 · 2 comments
Closed

_mxml_vstrdupf bug on Windows #245

ironxu opened this issue Feb 10, 2019 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ironxu
Copy link

ironxu commented Feb 10, 2019

You should place parameter values instead of variables that return 256 bytes of gibberish.

= >

temp [256]. /* Small buffer for first vsnprintf */

If (bytes < sizeof (temp))
{
/ *

  • Hey, the formatted string fits in the tiny buffer, so just dup that...
  • /

Return (strdup (temp));
}

The solution
if (bytes < sizeof(temp))
{
/*
* Hey, the formatted string fits in the tiny buffer, so just dup that...
*/
vsprintf_s(temp, 256, format, ap);
return (strdup(temp));
}

@michaelrsweet
Copy link
Owner

OK, so this is on Windows? Looks like the conditional code should be expanded so that the _vscprintf code immediately falls on the malloc and vsnprintf to the malloc'd buffer.

@michaelrsweet michaelrsweet self-assigned this Feb 10, 2019
@michaelrsweet michaelrsweet added the bug Something isn't working label Feb 10, 2019
@michaelrsweet michaelrsweet modified the milestones: Stable, v3.0 Feb 10, 2019
@michaelrsweet michaelrsweet changed the title [The solution]_mxml_vstrdupf _mxml_vstrdupf bug on Windows Feb 10, 2019
@michaelrsweet
Copy link
Owner

[master a69fcbc] Fix _mxml_vsnprintf on Windows (Issue #245)

woollybah added a commit to woollybah/mxml that referenced this issue Feb 12, 2019
* Fix makesrcdist script's archive generation (Issue michaelrsweet#242)

* Add CDATA test of varying lengths, as it looks like we might have yet another
MS C runtime issue with va_copy... :/

* The `mxmlSetOpaquef` and `mxmlSetTextf` functions did not work (Issue michaelrsweet#244)

Use _mxml_vstrdupf function, not _mxml_strdupf.

* Fix _mxml_vsnprintf on Windows (Issue michaelrsweet#245)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants