tmpfile: fix out-of-memory check
another catch by cppcheck * src/misc/tmpfile.cc: Here.
This commit is contained in:
parent
340557a12d
commit
65c0cb48fc
1 changed files with 3 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2013 Laboratoire de Recherche et Développement
|
// Copyright (C) 2013, 2015 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -52,10 +52,9 @@ namespace spot
|
||||||
size_t slen = 0;
|
size_t slen = 0;
|
||||||
if (suffix)
|
if (suffix)
|
||||||
len += slen = strlen(suffix);
|
len += slen = strlen(suffix);
|
||||||
*name = static_cast<char*>(malloc(tmpdirlen + 1 + len + 6 + 1));
|
char* x = *name = static_cast<char*>(malloc(tmpdirlen + 1 + len + 6 + 1));
|
||||||
if (!name)
|
if (!x)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
char* x = *name;
|
|
||||||
if (tmpdir)
|
if (tmpdir)
|
||||||
{
|
{
|
||||||
x = stpcpy(x, tmpdir);
|
x = stpcpy(x, tmpdir);
|
||||||
|
|
@ -147,4 +146,3 @@ namespace spot
|
||||||
delete to_clean.front();
|
delete to_clean.front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue