Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_memset4() freeze #166

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

SDL_memset4() freeze #166

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.0
Reported for operating system, platform: Other, Other

Comments on the original bug report:

On 2009-05-28 15:57:32 +0000, Jehan wrote:

When below SDL_memset4() is called with len = 0. SW is freezing on Iphone platform.

#define SDL_memset4(dst, val, len)
do {
unsigned _count = (len);
unsigned _n = (_count + 3) / 4;
Uint32 *_p = SDL_static_cast(Uint32 *, dst);
Uint32 _val = (val);
switch (_count % 4) {
case 0: do { *_p++ = _val;
case 3: *_p++ = _val;
case 2: *_p++ = _val;
case 1: *_p++ = _val;
} while ( --_n );
}
} while(0)

Indeed if we enter the loop when n=0. We will be locked into an infinite loop due to pre-increment (--n).

I assume that this function should just return if len == 0, Do you agree?

I suggest a break when entering the do{}whiile(0) : if(!len) break;

On 2009-06-25 10:58:05 +0000, Ozkan Sezer wrote:

Is SDL-1.2 not affected?

On 2009-08-07 03:20:56 +0000, Sam Lantinga wrote:

Yep, this affected SDL 1.2 as well. This is now fixed for both versions.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant