Skip to content

Commit ddded2e

Browse files
Ensure that memory that is allocated by SODA is actually freed; ensure
that the method is only called with the supported client version.
1 parent 7ba8ed0 commit ddded2e

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/dpiSodaColl.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -312,30 +312,36 @@ int dpiSodaColl__listIndexes(dpiSodaColl *coll, uint32_t flags,
312312
dpiStringList *list, dpiError *error)
313313
{
314314
uint32_t ptrLen, numAllocatedStrings = 0;
315+
void *listHandle = NULL;
315316
void **elem, *elemInd;
316317
int32_t i, listLen;
317-
void *listHandle;
318-
int exists;
318+
int exists, status;
319319
char *ptr;
320320

321-
if (dpiOci__sodaIndexList(coll, flags, &listHandle, error) < 0)
321+
if (dpiUtils__checkClientVersionMulti(coll->env->versionInfo, 19, 13,
322+
21, 3, error) < 0)
322323
return DPI_FAILURE;
323-
if (dpiOci__collSize(coll->db->conn, listHandle, &listLen, error) < 0)
324+
if (dpiOci__sodaIndexList(coll, flags, &listHandle, error) < 0)
324325
return DPI_FAILURE;
325-
for (i = 0; i < listLen; i++) {
326-
if (dpiOci__collGetElem(coll->db->conn, listHandle, i, &exists,
327-
(void**) &elem, &elemInd, error) < 0)
328-
return DPI_FAILURE;
329-
if (dpiOci__stringPtr(coll->env->handle, *elem, &ptr) < 0)
330-
return DPI_FAILURE;
331-
if (dpiOci__stringSize(coll->env->handle, *elem, &ptrLen) < 0)
332-
return DPI_FAILURE;
333-
if (dpiStringList__addElement(list, ptr, ptrLen, &numAllocatedStrings,
334-
error) < 0)
335-
return DPI_FAILURE;
326+
status = dpiOci__collSize(coll->db->conn, listHandle, &listLen, error);
327+
for (i = 0; i < listLen && status == DPI_SUCCESS; i++) {
328+
status = dpiOci__collGetElem(coll->db->conn, listHandle, i, &exists,
329+
(void**) &elem, &elemInd, error);
330+
if (status < 0)
331+
break;
332+
status = dpiOci__stringPtr(coll->env->handle, *elem, &ptr);
333+
if (status < 0)
334+
break;
335+
status = dpiOci__stringSize(coll->env->handle, *elem, &ptrLen);
336+
if (status < 0)
337+
break;
338+
status = dpiStringList__addElement(list, ptr, ptrLen,
339+
&numAllocatedStrings, error);
336340
}
337341

338-
return DPI_SUCCESS;
342+
if (listHandle)
343+
dpiOci__objectFree(coll->env->handle, listHandle, 0, error);
344+
return status;
339345
}
340346

341347

0 commit comments

Comments
 (0)