Skip to content

Commit

Permalink
Fixed bug #8897 - SDL_BlitSurface segfault when dest_rect is null
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Jan 22, 2024
1 parent ed5d3d9 commit 237535b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/video/SDL_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect,
if (dstrect) { /* update output parameter */
*dstrect = r_dst;
}
return SDL_LowerBlit(src, &r_src, dst, dstrect);
return SDL_LowerBlit(src, &r_src, dst, &r_dst);
}

end:
Expand Down

4 comments on commit 237535b

@sezero
Copy link
Contributor

@sezero sezero commented on 237535b Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to update output parameter after SDL_LowerBlit() ?

@sezero
Copy link
Contributor

@sezero sezero commented on 237535b Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, something like:

diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -771,6 +771,7 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect,
     if (r_dst.w > 0 && r_dst.h > 0) {
+        int ret = SDL_LowerBlit(src, &r_src, dst, &r_dst);
         if (dstrect) { /* update output parameter */
             *dstrect = r_dst;
         }
-        return SDL_LowerBlit(src, &r_src, dst, &r_dst);
+        return ret;
     }

I may be off base here, though..

@1bsyl
Copy link
Contributor Author

@1bsyl 1bsyl commented on 237535b Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not needed:
protype is const for dstrect / not modified :

SDL_BlitSurfaceUnchecked / LowerBlit is (SDL_Surface *src, const SDL_Rect *srcrect,
                              SDL_Surface *dst, const SDL_Rect *dstrect)

@slouken
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was my mistake in the merge, sorry!

Please sign in to comment.