Commit be2210b
fix(LDAPObject): Prevent memory errors in attrs_from_List
Function `PySequence_Length` can return -1 on iterables like `dict`.
The following PyMem_NEW still succeeds due `PyMem_NEW(char *, -1 + 1)`
being equivalent to `char** PyMem_Malloc(1)`, which then can result in a
segmentation fault later on.
Solution: Use `seq` and `PySequence_Size` to determine the size of
the sequence. This way any iterable which contains only strings can be used.
Co-authored-by: Christian Heimes <christian@python.org>1 parent 0c66d06 commit be2210b
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
292 | 295 | | |
293 | 296 | | |
294 | 297 | | |
| |||
0 commit comments