use MemoryDeleter to make sure we free 'flattenedRuns' on error, in every case. CID 905
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27514 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
697dfc3e47
commit
59afe07d2c
@ -8,6 +8,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ;
|
||||
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Translator RTF-Translator :
|
||||
# RTFTranslator classes
|
||||
main.cpp
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <Node.h>
|
||||
#include <Font.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -573,6 +575,8 @@ convert_to_stxt(RTF::Header &header, BDataIO &target)
|
||||
return status;
|
||||
}
|
||||
|
||||
BPrivate::MemoryDeleter _(flattenedRuns);
|
||||
|
||||
// put out styles
|
||||
|
||||
TranslatorStyledTextStyleHeader styleHeader;
|
||||
@ -584,7 +588,7 @@ convert_to_stxt(RTF::Header &header, BDataIO &target)
|
||||
|
||||
status = swap_data(B_UINT32_TYPE, &styleHeader, sizeof(styleHeader),
|
||||
B_SWAP_HOST_TO_BENDIAN);
|
||||
if (status != B_OK)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
written = target.Write(&styleHeader, sizeof(styleHeader));
|
||||
@ -596,8 +600,6 @@ convert_to_stxt(RTF::Header &header, BDataIO &target)
|
||||
// output actual style information
|
||||
written = target.Write(flattenedRuns, flattenedSize);
|
||||
|
||||
free(flattenedRuns);
|
||||
|
||||
if (written < B_OK)
|
||||
return written;
|
||||
if (written != flattenedSize)
|
||||
|
Loading…
Reference in New Issue
Block a user