Commit c06a829
committed
Fix segfault in Record.get() with invalid positional arg count
record_get() set a TypeError with PyErr_Format() when given the wrong
number of positional arguments but did not return, falling through to
record_item_by_name() with an uninitialized `key` pointer. Depending on
the stack contents this either crashed the interpreter (SEGV) or silently
returned the default instead of raising TypeError. The release build also
emitted a `'key' may be used uninitialized` warning.
Return NULL immediately after setting the error, and add regression
coverage for the invalid argument-count cases.
Fixes #1328.1 parent db8ecc2 commit c06a829
2 files changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
| 695 | + | |
695 | 696 | | |
696 | 697 | | |
697 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
291 | 301 | | |
292 | 302 | | |
293 | 303 | | |
| |||
0 commit comments