Skip to content

Commit fcaed54

Browse files
naxIOclaude
andcommitted
Fix cross-compile, stale artifacts, packaging errors, and memory leaks
- Set cross-compile flags based on host architecture so universal builds work on both Intel and Apple Silicon Macs - Remove stale ffmpeg/universal dir before single-arch builds to prevent linking against outdated libs - Add error checking to plugin packaging (RESULT_VARIABLE + FATAL_ERROR) - Fix memory leaks in ConfigModel: use stack allocation instead of malloc without free Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7732dad commit fcaed54

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

create-pluginfile.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ if(WIN32)
1515
execute_process(
1616
COMMAND "C:/Program Files/7-Zip/7z.exe" a "${PLUGIN_OUTPUT}" -tzip -mx=9 -mm=Deflate "*"
1717
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
18+
RESULT_VARIABLE zip_result
1819
)
1920
else()
2021
# Use zip on Linux/macOS
2122
execute_process(
2223
COMMAND zip -r -9 "${PLUGIN_OUTPUT}" .
2324
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
25+
RESULT_VARIABLE zip_result
2426
)
2527
endif()
28+
29+
if(NOT zip_result EQUAL 0)
30+
message(FATAL_ERROR "Failed to create plugin package (exit code: ${zip_result})")
31+
endif()

ffmpeg/build-scripts/build_ffmpeg.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,24 @@ build_single_arch() {
356356
}
357357

358358
if [[ "$build_mac_universal" == "true" ]]; then
359-
# Build arm64 (native on Apple Silicon)
359+
host_arch="$(uname -m)"
360+
cross_compile_flags="--enable-cross-compile --target-os=darwin"
361+
362+
# Build arm64 (cross-compile on Intel, native on Apple Silicon)
360363
echo "=== Building FFmpeg for arm64 ==="
361-
build_single_arch "aarch64" "arm64" "clang -arch arm64" ""
364+
if [[ "$host_arch" == "x86_64" ]]; then
365+
build_single_arch "aarch64" "arm64" "clang -arch arm64" "$cross_compile_flags"
366+
else
367+
build_single_arch "aarch64" "arm64" "clang -arch arm64" ""
368+
fi
362369

363-
# Build x86_64 (cross-compile on Apple Silicon)
370+
# Build x86_64 (native on Intel, cross-compile on Apple Silicon)
364371
echo "=== Building FFmpeg for x86_64 ==="
365-
build_single_arch "x86_64" "x64" "clang -arch x86_64" "--enable-cross-compile --target-os=darwin"
372+
if [[ "$host_arch" == "arm64" ]]; then
373+
build_single_arch "x86_64" "x64" "clang -arch x86_64" "$cross_compile_flags"
374+
else
375+
build_single_arch "x86_64" "x64" "clang -arch x86_64" ""
376+
fi
366377

367378
# Combine into universal binaries using lipo
368379
echo "=== Creating universal binaries with lipo ==="
@@ -379,6 +390,9 @@ if [[ "$build_mac_universal" == "true" ]]; then
379390

380391
./copy_binaries.sh
381392
else
393+
# Remove stale universal artifacts to prevent copy_binaries.sh from
394+
# copying outdated libs into lib_mac_universal
395+
rm -rf ../ffmpeg/universal
382396
build_single_arch "$arch" "$archprefix" "" ""
383397
./copy_binaries.sh
384398
fi

src/ConfigModel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void ConfigModel::setSoundInfo( int itemId, const SoundInfo &info )
221221
QString ConfigModel::GetConfigPath()
222222
{
223223
// Find config path for config class
224-
char* configPath = (char*)malloc(PATH_BUFSIZE);
224+
char configPath[PATH_BUFSIZE];
225225
ts3Functions.getConfigPath(configPath, PATH_BUFSIZE);
226226
return QString::fromUtf8(configPath);
227227
}
@@ -433,7 +433,7 @@ void ConfigModel::setBubbleColsBuild(int build)
433433
//---------------------------------------------------------------
434434
std::vector<SoundInfo> ConfigModel::getInitialSounds()
435435
{
436-
char* pluginPath = (char*)malloc(PATH_BUFSIZE);
436+
char pluginPath[PATH_BUFSIZE];
437437
ts3Functions.getPluginPath(pluginPath, PATH_BUFSIZE, getPluginID());
438438
QString fullPath = QString::fromUtf8(pluginPath);
439439
QChar last = fullPath[fullPath.count() - 1];

0 commit comments

Comments
 (0)