def MXNDArrayGetStorageType(handle, storage_type=-1):
'''
Exercise the vulnerable code path in src/c_api/c_api.cc
int MXNDArrayGetStorageType(NDArrayHandle handle,
int *out_storage_type) {
API_BEGIN();
NDArray *arr = static_cast<NDArray*>(handle);
if (!arr->is_none()) {
*out_storage_type = arr->storage_type();
} else {
*out_storage_type = kUndefinedStorage;
}
API_END();
}
'''
global URL
path = '/get_storage_type'
params = {}
params['handle'] = handle
if storage_type != -1:
params['storage_type'] = storage_type
response = requests.get(URL+path, params=params)
ret = int(json.loads(response.text)['result'])
return ret