OSDN Git Service
(root)
/
winmerge-jp
/
winmerge-jp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
32eef6c
)
Cppcheck: Common realloc mistake: 'ptr' nulled but not freed upon failure
author
sdottaka
<none@none>
Sun, 21 Apr 2013 12:53:30 +0000
(21:53 +0900)
committer
sdottaka
<none@none>
Sun, 21 Apr 2013 12:53:30 +0000
(21:53 +0900)
Src/Common/unicoder.cpp
patch
|
blob
|
history
diff --git
a/Src/Common/unicoder.cpp
b/Src/Common/unicoder.cpp
index
5f2147f
..
eb56494
100644
(file)
--- a/
Src/Common/unicoder.cpp
+++ b/
Src/Common/unicoder.cpp
@@
-818,7
+818,10
@@
void buffer::resize(size_t newSize)
if (capacity < newSize)
{
capacity = newSize;
- ptr = (unsigned char *)realloc(ptr, capacity);
+ unsigned char *tmp = static_cast<unsigned char *>(realloc(ptr, capacity));
+ if (!tmp)
+ throw std::bad_alloc();
+ ptr = tmp;
}
}