I just accidentally found a literal zip bomb for the ram in love
Posted: Sat Sep 23, 2023 1:35 am
Hey guys with little boilerplate i'll go directly to the "Thing",
so i trying to develop a game and one of the features is video on the level's background, i was implementing the logic of pause menu (You can roast me btw):
The supposed logic goal was that whenever the pause menu was on screen well is supposed to be a pause menu right? so we pause the video and resume after, my oversight was that once you unpaused, the thing will just spam the hell outta , and i kid you not it just needed 3 seconds to fill my entire ram (8gb 7.9 usable - 2gb used by the system), apparently when called repeadtedly the play() method generates a lot of garbage i do not treat it as a bug since i'm supposed to call it once. but i thought that was worth the share of that oversight of mine.
Also the fix was dirty cheap for those wondering (roast allowed again):
But i'm also considering adding the check when paused as well just to play it safe
so i trying to develop a game and one of the features is video on the level's background, i was implementing the logic of pause menu (You can roast me btw):
Code: Select all
local function advanceTime(dt)
if type("mediaContent") then
local success, res = pcall(mediaContent.tell, mediaContent)
if success then
elapsedTime = res or 0
else
print(res)
end
--What i added, that caused the mayhem
if type(menu) == "table" then
if menu.show then
waveSource:pause()
mediaContent:pause()
else
mediaContent:play()
waveSource:play()
end
end
end
end
Code: Select all
play()
Also the fix was dirty cheap for those wondering (roast allowed again):
Code: Select all
local function advanceTime(dt)
if type("mediaContent") then
local success, res = pcall(mediaContent.tell, mediaContent)
if success then
elapsedTime = res or 0
else
print(res)
end
if type(menu) == "table" then
if menu.show then
waveSource:pause()
mediaContent:pause()
else
if mediaContent:tell() > 0 and not mediaContent:isPlaying() then
mediaContent:play()
waveSource:play()
end
end
end
end
end