Commit 304c4a50 authored by Sam Lantinga's avatar Sam Lantinga

Merged fix for bug #457 from SDL 1.2

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402545
parent e2898c73
...@@ -1399,6 +1399,11 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay) ...@@ -1399,6 +1399,11 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay)
{ {
void *pixels; void *pixels;
int pitch; int pitch;
if (!overlay) {
SDL_SetError("Passed a NULL overlay");
return -1;
}
if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
< 0) { < 0) {
return -1; return -1;
...@@ -1424,12 +1429,19 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay) ...@@ -1424,12 +1429,19 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay)
void void
SDL_UnlockYUVOverlay(SDL_Overlay * overlay) SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
{ {
if (!overlay) {
return;
}
SDL_UnlockTexture(overlay->hwdata->textureID); SDL_UnlockTexture(overlay->hwdata->textureID);
} }
int int
SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
{ {
if (!overlay || !dstrect) {
SDL_SetError("Passed a NULL overlay or dstrect");
return -1;
}
if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) { if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) {
return -1; return -1;
} }
...@@ -1440,15 +1452,16 @@ SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) ...@@ -1440,15 +1452,16 @@ SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
void void
SDL_FreeYUVOverlay(SDL_Overlay * overlay) SDL_FreeYUVOverlay(SDL_Overlay * overlay)
{ {
if (overlay) { if (!overlay) {
if (overlay->hwdata) { return;
if (overlay->hwdata->textureID) { }
SDL_DestroyTexture(overlay->hwdata->textureID); if (overlay->hwdata) {
} if (overlay->hwdata->textureID) {
SDL_free(overlay->hwdata); SDL_DestroyTexture(overlay->hwdata->textureID);
} }
SDL_free(overlay); SDL_free(overlay->hwdata);
} }
SDL_free(overlay);
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment