From 894a44f45c26fe3b5e577b00f32237b910364161 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 22 Oct 2016 21:32:44 -0300 Subject: [PATCH 1/4] Fix an incorrect delete call when out of memory. --- src/modules/graphics/opengl/GLBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/GLBuffer.cpp b/src/modules/graphics/opengl/GLBuffer.cpp index 4cee2f34a..8c7c482cc 100644 --- a/src/modules/graphics/opengl/GLBuffer.cpp +++ b/src/modules/graphics/opengl/GLBuffer.cpp @@ -279,7 +279,7 @@ QuadIndices::QuadIndices(size_t size) } catch (std::bad_alloc &) { - delete[] newbuffer; + delete newbuffer; delete[] newindices; throw love::Exception("Out of memory."); } From 295fff5db83350a988634ddd4ab93ede1ba8a022 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 23 Oct 2016 22:56:19 -0300 Subject: [PATCH 2/4] Testing whether appveyor can build with Windows XP support --- extra/appveyor/appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/appveyor/appveyor.yml b/extra/appveyor/appveyor.yml index e827408f9..0a8697e43 100644 --- a/extra/appveyor/appveyor.yml +++ b/extra/appveyor/appveyor.yml @@ -26,7 +26,7 @@ install: - move love libs\love before_build: -- cmake -G "Visual Studio 12" -H. -Bbuild +- cmake -G "Visual Studio 12" -H. -Bbuild -T v120_xp build_script: - cmake --build build --target PACKAGE --config Release From d57ce8ae73e072f7ad323454462ebbe2202debb5 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 23 Oct 2016 23:00:46 -0300 Subject: [PATCH 3/4] The answer is no :( --- extra/appveyor/appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/appveyor/appveyor.yml b/extra/appveyor/appveyor.yml index 0a8697e43..e827408f9 100644 --- a/extra/appveyor/appveyor.yml +++ b/extra/appveyor/appveyor.yml @@ -26,7 +26,7 @@ install: - move love libs\love before_build: -- cmake -G "Visual Studio 12" -H. -Bbuild -T v120_xp +- cmake -G "Visual Studio 12" -H. -Bbuild build_script: - cmake --build build --target PACKAGE --config Release From ff53e8fe7121bc66a010ea92cccc4f46552b9d7f Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 24 Oct 2016 18:14:09 -0300 Subject: [PATCH 4/4] Fix non-integer coordinates passed to ImageData:mapPixel/setPixel/getPixel and SoundData:set/getSample. LuaJIT does interesting things when you index into a FFI array using a non-integer value. --- src/modules/image/wrap_ImageData.lua | 12 ++++++++++++ src/modules/sound/wrap_SoundData.lua | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/modules/image/wrap_ImageData.lua b/src/modules/image/wrap_ImageData.lua index 22fbc451b..ddc0e7fd4 100644 --- a/src/modules/image/wrap_ImageData.lua +++ b/src/modules/image/wrap_ImageData.lua @@ -27,6 +27,7 @@ local ImageData = ImageData_mt.__index local tonumber, assert, error = tonumber, assert, error local type, pcall = type, pcall +local floor = math.floor local function inside(x, y, w, h) return x >= 0 and x < w and y >= 0 and y < h @@ -126,6 +127,11 @@ function ImageData:_mapPixelUnsafe(func, ix, iy, iw, ih) local p = objectcache[self] local idw, idh = p.width, p.height + ix = floor(ix) + iy = floor(iy) + iw = floor(iw) + ih = floor(ih) + local pixels = p.pointer for y=iy, iy+ih-1 do @@ -144,6 +150,9 @@ function ImageData:getPixel(x, y) if type(x) ~= "number" then error("bad argument #1 to ImageData:getPixel (expected number)", 2) end if type(y) ~= "number" then error("bad argument #2 to ImageData:getPixel (expected number)", 2) end + x = floor(x) + y = floor(y) + local p = objectcache[self] if not inside(x, y, p.width, p.height) then error("Attempt to get out-of-range pixel!", 2) end @@ -161,6 +170,9 @@ function ImageData:setPixel(x, y, r, g, b, a) if type(x) ~= "number" then error("bad argument #1 to ImageData:setPixel (expected number)", 2) end if type(y) ~= "number" then error("bad argument #2 to ImageData:setPixel (expected number)", 2) end + x = floor(x) + y = floor(y) + if type(r) == "table" then local t = r r, g, b, a = t[1], t[2], t[3], t[4] diff --git a/src/modules/sound/wrap_SoundData.lua b/src/modules/sound/wrap_SoundData.lua index 803a9a2d1..e74482397 100644 --- a/src/modules/sound/wrap_SoundData.lua +++ b/src/modules/sound/wrap_SoundData.lua @@ -35,6 +35,7 @@ local status, ffi = pcall(require, "ffi") if not status then return end local tonumber, assert, error = tonumber, assert, error +local floor = math.floor local float = ffi.typeof("float") local datatypes = {ffi.typeof("uint8_t *"), ffi.typeof("int16_t *")} @@ -77,6 +78,8 @@ local objectcache = setmetatable({}, { function SoundData:getSample(i) if type(i) ~= "number" then error("bad argument #1 to SoundData:getSample (expected number)", 2) end + i = floor(i) + local p = objectcache[self] if not (i >= 0 and i < p.size/p.bytedepth) then @@ -96,6 +99,8 @@ function SoundData:setSample(i, sample) if type(i) ~= "number" then error("bad argument #1 to SoundData:setSample (expected number)", 2) end if type(sample) ~= "number" then error("bad argument #2 to SoundData:setSample (expected number)", 2) end + i = floor(i) + local p = objectcache[self] if not (i >= 0 and i < p.size/p.bytedepth) then