fix: code quality improvements across C codebase

- Replace sprintf with snprintf (1024-byte errbuf) in hmmmm.c, base_device.c,
  compose_device.c, config.c
- Fix WRITE_MEM macro: use smartAddrWriteHandlers for write ident (was
  incorrectly reading from smartAddrReadHandlers)
- Replace alloca with malloc+free in dispatchMemAccessNotifications
- Guard closeBaseDevice against NULL lib/partial initialization
- Simplify intercept context storage to single contiguous allocation
- Add NULL checks after calloc in config handler with proper cleanup
- Guard find_device_by_id against zero-length path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 22:18:23 +00:00
parent eb7f4b7eb0
commit 71ec472510
7 changed files with 200 additions and 76 deletions

View File

@@ -32,7 +32,7 @@ typedef struct {
uint8_t** devicesMem;
size_t devicesCount;
void** deviceHandles; // device_handle_t** — dynamically loaded devices
void** interceptCtxs; // intercept_ctx_t** — heap-allocated intercept contexts
void* interceptCtxs; // contiguous intercept_ctx_t array (freed as single block)
size_t interceptCtxCount;
flatcc_builder_t stream_builder;
} EmulContext;