Repository navigation
Commit eb512d2
committed
Fix refcounting bugs in the refdb backend write callback
pygit2_refdb_backend_write() passed owned objects to Py_BuildValue()
with the N format, which takes ownership, then decref'd the same
objects again in the shared cleanup block — a double DECREF that can
lead to use-after-free. It also passed a borrowed reference to the
Py_True/Py_False singleton with N, and the error path called
Py_DECREF() on possibly NULL pointers.
Restructure the function with early returns so each failure point
releases exactly the objects it owns, and pass a new reference for
the force flag via PyBool_FromLong().
Fixes #1471
Assisted-by: Kimi Code1 parent 258bf55 commit eb512d2
1 file changed
Lines changed: 26 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | 213 | | |
216 | 214 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
228 | 240 | | |
229 | 241 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 242 | + | |
235 | 243 | | |
236 | 244 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
| |||
0 commit comments