Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Fix 3 memory leaks in AutoPatcher/ApplyPatch.cpp #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

png85
Copy link
Contributor

@png85 png85 commented Jul 8, 2014

This PR fixes three memory leaks in the AutoPatcher code:

ApplyPatch.cpp:288: patch = new char[patchSize];
ApplyPatch.cpp:289: old = new char[oldSize];
ApplyPatch.cpp:191: _new = new char[*newSize+1];

These buffers aren't deleted when returning from
int TestPatchInMemory(int argc, char*argv[])
at line 300 of the original sources, so (patchSize + oldSize + newSize + 1)
bytes of memory are leaked.

trotter and others added 5 commits July 8, 2014 10:51
This commit fixes a mismatching allocation/deallocation of a char array in
the AutoPatcher code:

CreatePatch.cpp:529: *out = new char[*outSize];
CreatePatch.cpp:579: free(out);

Mixing up new/delete and malloc/free is undefined behaviour and should be
avoided.
…rflow

Fix buffer overflow in chat server example
…ePatch-UB_fix

Fix mismatching allocation/deallocation in AutoPatcher/CreatePatch.cpp
@png85 png85 closed this Jul 10, 2014
@png85 png85 deleted the png.AutoPatcher_ApplyPatch-leak_fix branch July 10, 2014 11:36
@png85 png85 reopened this Jul 10, 2014
This commit fixes three memory leaks in the AutoPatcher code:

ApplyPatch.cpp:288: patch = new char[patchSize];
ApplyPatch.cpp:289: old = new char[oldSize];
ApplyPatch.cpp:191: _new = new char[*newSize+1];

These buffers aren't deleted when returning from
  int TestPatchInMemory(int argc, char*argv[])
at line 300 of the original sources, so (patchSize + oldSize + newSize + 1)
bytes of memory are leaked.
@Luke1410
Copy link

Changes to DependentExtensions/Autopatcher/ApplyPatch.cpp incorporated in SLikeNet 0.1.0 in a slightly modified way, so there's no double free in case ApplyPatch() already freed _new.

rhard pushed a commit to rhard/RakNet that referenced this pull request Oct 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants