fix: allocate transport in CLI test to prevent null pointer crash
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
13
test_cli.c
13
test_cli.c
@@ -24,6 +24,12 @@ static void test_cli_parse(void) {
|
|||||||
// Initialize atomic state mirrors
|
// Initialize atomic state mirrors
|
||||||
atomic_store(&engine.quantize_mode_atomic, (int)QUANTIZE_OFF);
|
atomic_store(&engine.quantize_mode_atomic, (int)QUANTIZE_OFF);
|
||||||
atomic_store(&engine.quantize_threshold_atomic, 0);
|
atomic_store(&engine.quantize_threshold_atomic, 0);
|
||||||
|
|
||||||
|
// Allocate and initialize transport
|
||||||
|
engine.transport = (Transport *)calloc(1, sizeof(Transport));
|
||||||
|
assert(engine.transport != NULL);
|
||||||
|
transport_init(engine.transport, 48000);
|
||||||
|
|
||||||
engine.transport->state = TRANSPORT_STOPPED;
|
engine.transport->state = TRANSPORT_STOPPED;
|
||||||
engine.transport->clock_count = 0;
|
engine.transport->clock_count = 0;
|
||||||
engine.transport->beat_position = 0;
|
engine.transport->beat_position = 0;
|
||||||
@@ -55,6 +61,13 @@ static void test_cli_parse(void) {
|
|||||||
assert(cli_process_line(&engine, "quantize") == 1);
|
assert(cli_process_line(&engine, "quantize") == 1);
|
||||||
assert(cli_process_line(&engine, "threshold") == 1);
|
assert(cli_process_line(&engine, "threshold") == 1);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
if (engine.transport) {
|
||||||
|
transport_cleanup(engine.transport);
|
||||||
|
free(engine.transport);
|
||||||
|
engine.transport = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
printf("PASSED\n");
|
printf("PASSED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user