Skip to content

Commit

Permalink
Fix memory leak in Python String reading
Browse files Browse the repository at this point in the history
Fix Memory Leak in Python Array reading

Use upload-artifacts-v4
Use download-artifacts-v4
  • Loading branch information
Brandon-T committed Sep 15, 2024
1 parent f3d93d7 commit 38cb892
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ jobs:
- name: 'Upload Artifacts - ${{ matrix.config.name }}'
if: github.event_name == 'push'
uses: actions/upload-artifact@v2.0.1
uses: actions/upload-artifact@v4
with:
overwrite: true
name: 'artifact-${{ matrix.config.name }}'
path: '${{ github.workspace }}/cmake-build-release/${{ matrix.config.release }}'

Release:
Expand Down Expand Up @@ -242,7 +244,15 @@ jobs:

- name: Download Artifacts
if: github.event_name == 'push'
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
pattern: 'artifact-*'
path: 'artifact'
merge-multiple: true

- name: List Artifacts
run: |
ls artifact
- name: Upload Autobuild
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')
Expand Down
2 changes: 1 addition & 1 deletion RemoteInput/Injection/Injector_Darwin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ bool Injector::Inject(std::string module_path, std::int32_t pid, void* bootstrap
//Retrieve a task port for the remote process..
mach_port_t remote_task = 0;
mach_error_t err = task_for_pid(mach_task_self(), pid, &remote_task);
if (err == 5)
if (err == KERN_FAILURE)
{
fprintf(stderr, "Could not access task for pid %d. You probably need to add user to procmod group\n", pid);
return false;
Expand Down
5 changes: 5 additions & 0 deletions RemoteInput/Plugin/Python/PythonCommon_Templates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ T from_python_object(PyObject* object)
Py_ssize_t size = 0;
char* buffer = nullptr;
python->PyBytes_AsStringAndSize(utf8_string, &buffer, &size);
(python->Py_XDECREF)(utf8_string);
return *buffer;
}
return -1;
Expand Down Expand Up @@ -329,6 +330,7 @@ T from_python_object(PyObject* object)
Py_ssize_t size = 0;
char* buffer = nullptr;
python->PyBytes_AsStringAndSize(utf8_string, &buffer, &size);
(python->Py_XDECREF)(utf8_string);
return std::string(buffer, size);
}
return std::string();
Expand All @@ -345,6 +347,7 @@ T from_python_object(PyObject* object)
Py_ssize_t size = 0;
char* buffer = nullptr;
python->PyBytes_AsStringAndSize(utf8_string, &buffer, &size);
(python->Py_XDECREF)(utf8_string);
return buffer;
}
return nullptr;
Expand Down Expand Up @@ -425,6 +428,8 @@ std::vector<T> from_python_array(PyObject* object)
result.push_back(from_python_object<T>(next));
}
}

(python->Py_DECREF)(iter);
}
return result;
}
Expand Down

0 comments on commit 38cb892

Please sign in to comment.