浏览代码

change: check allocated memory in vector::resize

greatbridf 2 年之前
父节点
当前提交
210279a15b
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      include/types/vector.hpp

+ 1 - 0
include/types/vector.hpp

@@ -173,6 +173,7 @@ public:
     constexpr void resize(size_type n)
     constexpr void resize(size_type n)
     {
     {
         value_type* new_ptr = allocator_traits<allocator_type>::allocate(n);
         value_type* new_ptr = allocator_traits<allocator_type>::allocate(n);
+        assert(!n || (n && new_ptr));
 
 
         m_capacity = n;
         m_capacity = n;
         size_t orig_size = m_size;
         size_t orig_size = m_size;