Cross-Platform Compatibility Fix - Phase 1

Goal

Fix test failures on Armbian Orange Pi 5 to ensure XMD passes all tests across all OS and environments.

Identified Issues

  1. Memory Corruption: malloc() corrupted top size in real_performance_tests
  2. Segfaults: upgrade_version_tests, cli_e2e_tests, sandbox_tests crash immediately
  3. Assertion Failures: String handling and output processing inconsistencies

Phase 1 Scope

Focus on memory management and string handling fixes in core components.

Target Files

  • src/memory/memory_allocate.c
  • src/string/string_duplicate.c
  • src/string/string_extract.c
  • src/variable/variable.c
  • src/template/template.c

Success Criteria

  • real_performance_tests passes without malloc corruption
  • String handling tests pass assertion checks
  • No memory leaks detected by valgrind

Implementation Order

  1. Fix memory allocation alignment issues
  2. Fix string handling buffer management
  3. Add proper null pointer checks
  4. Enhance error handling for edge cases