We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 653 - SDL SVN 1.3 2008-12-09, win32 platform, invalid memory free in SDL_win32mouse.c
Summary: SDL SVN 1.3 2008-12-09, win32 platform, invalid memory free in SDL_win32mouse.c
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: x86 Windows (All)
: P2 critical
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-10 01:22 UTC by Andrew
Modified: 2009-02-16 21:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew 2008-12-10 01:22:25 UTC
File SDL_win32mouse.c caused invalid memory de-allocation at line 129:
  SDL_free(buffer);

This is caused incorrect manipulation of pointer variable "buffer" at line 96:
  buffer += 4;
which is allocated at line 87:
  buffer = SDL_malloc((tmp + 1) * sizeof(char));

This bug is fixed by fast woraround adding at line 128 new line with:
        buffer -= 4;
just before if operator

Recommended to compelely review this section of code.

Also line 88 looks quite incorrect:
  key_name = SDL_malloc(tmp + sizeof(reg_key_root) * sizeof(char));
- tmp not multiplied by sizeof(char)
- size of char pointer counted instead of strlen
- not counted zero string end
Comment 1 Sam Lantinga 2009-02-16 21:29:26 UTC
It looks like this code was reviewed and fixed in revision 4334.

Thanks!