Eliminate reference leak with LOB values acquired from attributes of objects or

elements of collections.
This commit is contained in:
Anthony Tuininga 2018-02-02 15:45:21 -07:00
parent 99c019d6c5
commit 6e3b578281
2 changed files with 20 additions and 10 deletions

View File

@ -113,10 +113,6 @@ PyObject *cxoLob_new(cxoConnection *connection, dpiOracleTypeNum oracleTypeNum,
lob = (cxoLob*) cxoPyTypeLob.tp_alloc(&cxoPyTypeLob, 0);
if (!lob)
return NULL;
if (dpiLob_addRef(handle) < 0) {
Py_DECREF(lob);
return NULL;
}
lob->handle = handle;
lob->oracleTypeNum = oracleTypeNum;
Py_INCREF(connection);

View File

@ -405,12 +405,26 @@ PyObject *cxoVar_getSingleValue(cxoVar *var, uint32_t arrayPos)
Py_RETURN_NONE;
value = cxoTransform_toPython(var->type->transformNum, var->connection,
var->objectType, &data->value);
if (value && var->objectType)
dpiObject_addRef(data->value.asObject);
if (value && var->outConverter && var->outConverter != Py_None) {
result = PyObject_CallFunctionObjArgs(var->outConverter, value, NULL);
Py_DECREF(value);
return result;
if (value) {
switch (var->type->transformNum) {
case CXO_TRANSFORM_BFILE:
case CXO_TRANSFORM_BLOB:
case CXO_TRANSFORM_CLOB:
case CXO_TRANSFORM_NCLOB:
dpiLob_addRef(data->value.asLOB);
break;
case CXO_TRANSFORM_OBJECT:
dpiObject_addRef(data->value.asObject);
break;
default:
break;
}
if (var->outConverter && var->outConverter != Py_None) {
result = PyObject_CallFunctionObjArgs(var->outConverter, value,
NULL);
Py_DECREF(value);
return result;
}
}
return value;