summaryrefslogtreecommitdiffstats
path: root/bridges
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-17 13:55:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-18 11:27:14 +0200
commitfb1ef04ef8edac85f2d391c508e286621057fef6 (patch)
tree93c3e6265c0c1c34c82e1549e0ea917ba3e8ba55 /bridges
parentloplugin:useuniqueptr in ValueSet (diff)
downloadcore-fb1ef04ef8edac85f2d391c508e286621057fef6.tar.gz
core-fb1ef04ef8edac85f2d391c508e286621057fef6.zip
loplugin:useuniqueptr in VtableFactory::createBlock
Change-Id: I6fd0495277301dfa15bb456f30b8386aea86fe60 Reviewed-on: https://gerrit.libreoffice.org/60622 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'bridges')
-rw-r--r--bridges/source/cpp_uno/shared/vtablefactory.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/bridges/source/cpp_uno/shared/vtablefactory.cxx b/bridges/source/cpp_uno/shared/vtablefactory.cxx
index bbeedcaad3c3..4789b0341ebd 100644
--- a/bridges/source/cpp_uno/shared/vtablefactory.cxx
+++ b/bridges/source/cpp_uno/shared/vtablefactory.cxx
@@ -243,18 +243,17 @@ bool VtableFactory::createBlock(Block &block, sal_Int32 slotCount) const
strDirectory += "/.execoooXXXXXX";
OString aTmpName = OUStringToOString(strDirectory, osl_getThreadTextEncoding());
- char *tmpfname = new char[aTmpName.getLength()+1];
- strncpy(tmpfname, aTmpName.getStr(), aTmpName.getLength()+1);
+ std::unique_ptr<char[]> tmpfname(new char[aTmpName.getLength()+1]);
+ strncpy(tmpfname.get(), aTmpName.getStr(), aTmpName.getLength()+1);
// coverity[secure_temp] - https://communities.coverity.com/thread/3179
- if ((block.fd = mkstemp(tmpfname)) == -1)
- fprintf(stderr, "mkstemp(\"%s\") failed: %s\n", tmpfname, strerror(errno));
+ if ((block.fd = mkstemp(tmpfname.get())) == -1)
+ fprintf(stderr, "mkstemp(\"%s\") failed: %s\n", tmpfname.get(), strerror(errno));
if (block.fd == -1)
{
- delete[] tmpfname;
break;
}
- unlink(tmpfname);
- delete[] tmpfname;
+ unlink(tmpfname.get());
+ tmpfname.reset();
#if defined(HAVE_POSIX_FALLOCATE)
int err = posix_fallocate(block.fd, 0, block.size);
#else