Skip to content

Memory leak is possible for UDF array arguments #7817

@dmitry-lipetsk

Description

@dmitry-lipetsk

FB v4.0.4.2988

If this line throws

UCHAR* const temp = FB_NEW_POOL(*getDefaultMemoryPool()) UCHAR[static_cast<size_t>(to.dsc_length * n)];

you do not release the allocated memory in 'data'
UCHAR* data = FB_NEW_POOL(*getDefaultMemoryPool()) UCHAR[static_cast<size_t>(array_desc->iad_total_length)];

Bricks for reproducing this problem:

DECLARE EXTERNAL FUNCTION MY_UDF__GET_DIM
 INTEGER BY SCALAR_ARRAY
RETURNS INTEGER BY VALUE
ENTRY_POINT 'fn_get_dim__i4__sa'
MODULE_NAME 'lcpi.test.udf.01.dll'

select MY_UDF__GET_DIM(cast('12311111111111111111111111111111111111111111111111111111111111111111111111111111111' as blob)) from rdb$database

image

Memory releases after disconnect.

Metadata

Metadata