Skip to content

Commit

Permalink
Pathological error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbinns committed Jun 16, 2024
1 parent 2e1deed commit 8ab114c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,12 +2796,21 @@ apswvfsfile_xFileControl(sqlite3_file *file, int op, void *pArg)
#if PY_VERSION_HEX >= 0x030b0000
qualname = PyType_GetQualName(Py_TYPE(apswfile->file));
if (qualname && PyUnicode_Check(qualname))
name = PyUnicode_AsUTF8(qualname);
{
const char *tmp_name = PyUnicode_AsUTF8(qualname);
if (tmp_name)
name = tmp_name;
}
#endif

PyErr_Clear();

PyObject *module = PyObject_GetAttrString((PyObject *)Py_TYPE(apswfile->file), "__module__");
if (module && PyUnicode_Check(module))
{
modname = PyUnicode_AsUTF8(module);
PyErr_Clear();
}

/* the above calls could have exceptions but they aren't useful,
so ignore */
Expand All @@ -2818,10 +2827,13 @@ apswvfsfile_xFileControl(sqlite3_file *file, int op, void *pArg)
Py_XDECREF(module);
Py_XDECREF(qualname);

if (*(char **)pArg)
sqlite3_free(*(char **)pArg);
if (new_val)
{
if (*(char **)pArg)
sqlite3_free(*(char **)pArg);

*(char **)pArg = new_val;
*(char **)pArg = new_val;
}
result = SQLITE_OK;
goto end;
}
Expand Down

0 comments on commit 8ab114c

Please sign in to comment.