Skip to content

Commit

Permalink
guard these frees
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Oct 25, 2023
1 parent 8eb14d5 commit f69c258
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/winshortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
static PyObject *CreateShortcut(PyObject *self, PyObject *args)
{
PyObject *py_path; /* path and filename */
wchar_t *path;
wchar_t *path = NULL;
PyObject *py_description;
wchar_t *description;
wchar_t *description = NULL;
PyObject *py_filename;
wchar_t *filename;
wchar_t *filename = NULL;

PyObject *py_arguments = NULL;
PyObject *py_iconpath = NULL;
Expand Down Expand Up @@ -198,9 +198,15 @@ static PyObject *CreateShortcut(PyObject *self, PyObject *args)
pPersistFile->Release();
pShellLink->Release();

PyMem_Free(path);
PyMem_Free(description);
PyMem_Free(filename);
if (path) {
PyMem_Free(path);
}
if (description) {
PyMem_Free(description);
}
if (filename) {
PyMem_Free(filename);
}

Py_DECREF(py_path);
Py_DECREF(py_description);
Expand Down

0 comments on commit f69c258

Please sign in to comment.