Fix CTC context memory leak when input lengths are not allocated

上级 bff3df37
...@@ -130,6 +130,9 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations, ...@@ -130,6 +130,9 @@ int APPLY_SPECIFIC(ctc_cost_gpu)(PyGpuArrayObject * in_activations,
if ( NULL == context->input_lengths ) if ( NULL == context->input_lengths )
{ {
// Destroy previous CTC context before returning exception
ctc_context_destroy( context );
PyErr_Format( PyExc_MemoryError, PyErr_Format( PyExc_MemoryError,
"Could not allocate storage for input lengths" ); "Could not allocate storage for input lengths" );
return 1; return 1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论