DEADSOFTWARE

gl: fix crash on render finalization
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Thu, 16 Feb 2023 19:13:06 +0000 (22:13 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:15:00 +0000 (12:15 +0300)
src/game/renders/opengl/r_textures.pas

index ec47f58bc640ecd4d2a213246f19519ccaaef100..97d572c5776b02fac7f16af63070b832cc4933c0 100644 (file)
@@ -492,9 +492,12 @@ implementation
     begin
       for i := 0 to High(atl) do
       begin
-        glDeleteTextures(1, @atl[i].id);
-        atl[i].id := 0;
-        r_Common_FreeAndNil(atl[i]);
+        if atl[i] <> nil then
+        begin
+          glDeleteTextures(1, @atl[i].id);
+          atl[i].id := 0;
+          r_Common_FreeAndNil(atl[i]);
+        end;
       end;
     end;
     SetLength(atl, 0);
@@ -503,9 +506,12 @@ implementation
     begin
       for i := 0 to High(ratl) do
       begin
-        glDeleteTextures(1, @ratl[i].id);
-        ratl[i].id := 0;
-        r_Common_FreeAndNil(ratl[i]);
+        if ratl[i] <> nil then
+        begin
+          glDeleteTextures(1, @ratl[i].id);
+          ratl[i].id := 0;
+          r_Common_FreeAndNil(ratl[i]);
+        end;
       end;
     end;
     SetLength(ratl, 0);