zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 6f99b5a477577eacc369e2df7be7ec6e1df72528
parent 06ce6e64b2feb189096a81f1c81162dee79f47d5
Author: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com>
Date:   Fri, 17 Jul 2020 09:49:29 +0200

[WIN32] Fix problem of missing asprintf()

Since existing implementation does not check if asprintf() is executed successfully, I left modified code also in the same manner, to be sure that new code works exactly like the old one. Probably, it should just return an error, but the value is unknown to me.
Diffstat:
Msrc/UI/NSM.C | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/UI/NSM.C b/src/UI/NSM.C @@ -80,12 +80,14 @@ NSM_Client::command_open(const char *name, zyn::Nio::start(); - char *new_filename; + char *new_filename = (char *)malloc(strlen(name) + 5); - //if you're on windows enjoy the undefined behavior... -#ifndef WIN32 - asprintf(&new_filename, "%s.xmz", name); -#endif + if (new_filename) { + strcpy(new_filename, name); + strcat(new_filename, ".xmz"); + } else { + // TODO, handle error condition... + } struct stat st;