title: Breaks when return np.array using MinGW32
body: <p>I'm trying to build a python extension which has a function returns a np.array. But it breaks when compiled with MinGW32 but works with VS2019. I tried to comment the code setting the flag NPY_ARRAY_OWNDATA, then MinGW32 and VS2019 both work, but lead a memory leak.</p>
  <p>(I guess VS-built numpy cannot free memory which malloc by MinGW32.)</p>
  <p>Is it possible using MinGW32 with numpy?</p>
  <pre class="lang-c prettyprint-override"><code>static PyObject *py_Decode(PyObject *self, PyObject *args)
  {
    // Do something
  
    char *buffer = malloc(1024 * 1024 * 2);
    npy_intp dims[2] = {1024, 1024};
    PyObject *ret = PyArray_SimpleNewFromData(2, dims, NPY_SHORT, buffer);
    PyArray_ENABLEFLAGS((PyArrayObject *)ret, NPY_ARRAY_OWNDATA);  // When commented, mingw32 works, but memory leak.
    return ret; 
  }
  </code></pre>
  <p>I'm using:</p>
  <ul>
  <li>Python 3.8.3 32bit</li>
  <li>numpy 1.18.5</li>
  <li>VS2019 19.26.28806</li>
  <li>mingw32-gcc 9.2.0</li>
  </ul>