Resource leak (RESOURCE_LEAK) in source/common/ubidi.c in function setParaRunsOnly()
General
Trac Data
Other Data
General
Trac Data
Other Data
Description
When we are allocating a memory dynamically , the allocated memory must be free in all condition in failure and in success also.in the function setParaRuns() in source/common/ubidi.c, There is a chance of leaking memory.The assigned memory to runsOnlyMemory may be leaked at cleanup3: section.
When we are allocating a memory dynamically , the allocated memory must be free in all condition in failure and in success also.in the function setParaRuns() in source/common/ubidi.c, There is a chance of leaking memory.The assigned memory to runsOnlyMemory may be leaked at cleanup3: section.
Patch for this bug.
diff -Naurp a/source/common/ubidi.c b/source/common/ubidi.c
— a/source/common/ubidi.c 2014-08-28 16:11:29.114707222 +0530
+++ b/source/common/ubidi.c 2014-08-29 14:20:43.317621887 +0530
@@ -2513,11 +2513,18 @@
setParaRunsOnly(UBiDi *pBiDi, const UCha
pBiDi->trailingWSStart=saveTrailingWSStart;
/* free memory for mapping table and visual text */
uprv_free(runsOnlyMemory);
+ runsOnlyMemory=NULL;
if(pBiDi->runCount>1) {
pBiDi->direction=UBIDI_MIXED;
}
cleanup3:
pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
+ if(runsOnlyMemory != NULL)
+ {
+ pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
+ uprv_free(runsOnlyMemory);
+ }
+ else
+ pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
}
/* ubidi_setPara ------------------------------------------------------------ */