Commit e79eb40
fix: same defer-capture leak in destroyValueSlice (3 additional sites)
The same bug pattern exists for destroyValueSlice in value.go:
- inferSliceLogicalTypeAndValue (line 398): values := make([]Value, 0, length)
- createSliceValue (line 459): var values []Value
- createStructValue (line 487): var values []Value
All three use `defer destroyValueSlice(values)` where `values` is
nil or len=0 at the defer site. The deferred cleanup iterates over
zero elements and never calls DestroyValue on the C-allocated
duckdb_value objects.
These functions are called when binding STRUCT, LIST, or ARRAY values
via Appender or prepared statements. Each call leaks one C Value
object per element/field.
Not a double-free risk: DuckDB's Create*Value functions (CreateListValue,
CreateArrayValue, CreateStructValue) deep-copy the input values via
allocValues → duckdb_create_*_value. The original Value objects remain
owned by the caller and must be destroyed separately.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 62abb76 commit e79eb40
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
| 487 | + | |
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| |||
0 commit comments