Browse Source

Fix memleak in `_korlib.create_bump_LUT()`

pull/133/head
Adam Johnson 6 years ago
parent
commit
ad99f496f0
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 9
      korlib/bumpmap.cpp

9
korlib/bumpmap.cpp

@ -33,8 +33,9 @@ typedef struct {
extern "C" { extern "C" {
PyObject* create_bump_LUT(PyObject*, PyObject* args) { PyObject* create_bump_LUT(PyObject*, PyObject* args) {
const int kLUTHeight = 16; static const int kLUTHeight = 16;
const int kLUTWidth = 16; static const int kLUTWidth = 16;
static const int kBufSz = kLUTWidth * kLUTWidth * sizeof(uint32_t);
pyMipmap* pymipmap; pyMipmap* pymipmap;
if (!PyArg_ParseTuple(args, "O", &pymipmap)) { if (!PyArg_ParseTuple(args, "O", &pymipmap)) {
@ -54,7 +55,7 @@ PyObject* create_bump_LUT(PyObject*, PyObject* args) {
int startH = delH / 2 + 1; int startH = delH / 2 + 1;
int doneH = 0; int doneH = 0;
uint8_t* data = new uint8_t[texture->getTotalSize()]; uint8_t data[kBufSz];
uint32_t* pix = (uint32_t*)data; uint32_t* pix = (uint32_t*)data;
int i; int i;
@ -105,7 +106,7 @@ PyObject* create_bump_LUT(PyObject*, PyObject* args) {
} }
} }
texture->setImageData(data, texture->getTotalSize()); texture->setImageData(data, kBufSz);
Py_RETURN_NONE; Py_RETURN_NONE;
} }

Loading…
Cancel
Save