diff options
| author | Xing Xue <xingxue@outlook.com> | 2019-06-25 15:08:28 +0000 |
|---|---|---|
| committer | Xing Xue <xingxue@outlook.com> | 2019-06-25 15:08:28 +0000 |
| commit | ece53d0ae50a97e42bf99180ab4344352cea2d04 (patch) | |
| tree | 7deb2248fe9c0b3f7e6cb8763320d4405f1e443f /llvm/lib/Analysis/OptimizationRemarkEmitter.cpp | |
| parent | 36c23cad151ade2ce1350c955ea7fd0ea9dcc674 (diff) | |
| download | bcm5719-llvm-ece53d0ae50a97e42bf99180ab4344352cea2d04.tar.gz bcm5719-llvm-ece53d0ae50a97e42bf99180ab4344352cea2d04.zip | |
Improve zero-size allocation with safe_malloc, etc.
Summary:
The current implementations of the memory allocation functions mistake a nullptr returned from std::malloc, std::calloc, or std::realloc as a failure. The behaviour for each of std::malloc, std::calloc, and std::realloc when the size is 0 is implementation defined (ISO/IEC 9899:2018 7.22.3), and may return a nullptr.
This patch checks if space requested is zero when a nullptr is returned, retry requesting non-zero if it is.
Authored By: andusy
Reviewers: hubert.reinterpretcast, xingxue, jasonliu
Reviewed By: hubert.reinterpretcast, xingxue, abrachet
Subscribers: abrachet, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63668
llvm-svn: 364322
Diffstat (limited to 'llvm/lib/Analysis/OptimizationRemarkEmitter.cpp')
0 files changed, 0 insertions, 0 deletions

