Sneeds-Feed-and-Seed / sneedacity

Audio Editor
https://sneedacity.org
Other
886 stars 62 forks source link

Fix Mac build crashes #297 #298

Closed drkvogel closed 1 year ago

drkvogel commented 2 years ago

Mac Wrapper: only strncpy SNEEDACITY_LEN bytes and set argv[0] to new path

Resolves: Mac build crashes #297

In the Mac Wrapper, mac/Wrapper.c this line:

strncpy(++slash, sneedacity, exlen);

was copying far too many characters (e.g. 94, on my system) in order to just copy the string "Sneedacity\0", and padding with zeros, which was corrupting the stack and leading to different behaviours in different environments - not running the main app at all in Xcode, crashing when the app bundle was run from Finder, and working successfully when Wrapper was called from the terminal.

I changed the length given to strncpy to SNEEDACITY_LEN (11):

strncpy(++slash, sneedacity, SNEEDACITY_LEN);

and also set argv[0] to the new path now ending in "Sneedacity" rather than "Wrapper"

argv[0] = path;
Ckath commented 2 years ago

its a shame theres no mac builds in the checks but if all else still builds I'll go for merging it

Ckath commented 1 year ago

it did build, think almost a year is long enough