Creative Post For Instagram

Office Cleaning Business Cards

inverdes espacios trascendentes

:
How To Do A Biography
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 Product Launch Icon Red Assisted-by: Kimi Code
1 parent Alternate CTA Copy For Read The Full Article commit eb512d2

Times Articles Book 1 file changed Foldable Business Cards

Lines changed: 26 additions & 21 deletions

Red Curved Arrow Office Cleaning Business Cards

src/refdb_backend.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,33 +210,38 @@ pygit2_refdb_backend_write(git_refdb_backend *_be,
210210
const git_signature *_who, const char *message,
211211
const git_oid *_old, const char *old_target)
212212
{
213-
int err;
214-
PyObject *args = NULL, *ref = NULL, *who = NULL, *old = NULL;
215213
struct pygit2_refdb_backend *be = (struct pygit2_refdb_backend *)_be;
216214

217-
// XXX: Drops const
218-
if ((ref = wrap_reference((git_reference *)_ref, NULL)) == NULL)
219-
goto euser;
220-
if ((who = build_signature(NULL, _who, "utf-8")) == NULL)
221-
goto euser;
222-
if ((old = git_oid_to_python(_old)) == NULL)
223-
goto euser;
224-
if ((args = Py_BuildValue("(NNNsNs)", ref,
225-
force ? Py_True : Py_False,
226-
who, message, old, old_target)) == NULL)
227-
goto euser;
215+
PyObject *ref = wrap_reference((git_reference *)_ref, NULL); // XXX: Drops const
216+
if (ref == NULL) {
217+
return GIT_EUSER;
218+
}
219+
220+
PyObject *who = build_signature(NULL, _who, "utf-8");
221+
if (who == NULL) {
222+
Py_DECREF(ref);
223+
return GIT_EUSER;
224+
}
225+
226+
PyObject *old = git_oid_to_python(_old);
227+
if (old == NULL) {
228+
Py_DECREF(ref);
229+
Py_DECREF(who);
230+
return GIT_EUSER;
231+
}
232+
233+
// Py_BuildValue takes ownership of ref, who and old (N format), even on failure, so
234+
// they must not be decref'd past this point.
235+
PyObject *args = Py_BuildValue("(NNNsNs)", ref, PyBool_FromLong(force), who, message,
236+
old, old_target);
237+
if (args == NULL) {
238+
return GIT_EUSER;
239+
}
228240

229241
PyObject_CallObject(be->write, args);
230-
err = git_error_for_exc();
231-
out:
232-
Py_DECREF(ref);
233-
Py_DECREF(who);
234-
Py_DECREF(old);
242+
int err = git_error_for_exc();
235243
Py_DECREF(args);
236244
return err;
237-
euser:
238-
err = GIT_EUSER;
239-
goto out;
240245
}
241246

242247
static int

Template Product To Present Office Cleaning Business Cards

Comments
 (0)