From 6e5febe96410650957404461f68942c638ed94b5 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 27 Feb 2018 08:53:46 +0100 Subject: [PATCH] ARROW-2210: [C++] Reset ptr on failed memory allocation --- cpp/src/arrow/memory_pool.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc index b8cd9c2fcf9..dedab7ea729 100644 --- a/cpp/src/arrow/memory_pool.cc +++ b/cpp/src/arrow/memory_pool.cc @@ -107,10 +107,12 @@ class DefaultMemoryPool : public MemoryPool { Status Reallocate(int64_t old_size, int64_t new_size, uint8_t** ptr) override { #ifdef ARROW_JEMALLOC + uint8_t* previous_ptr = *ptr; *ptr = reinterpret_cast(rallocx(*ptr, new_size, MALLOCX_ALIGN(kAlignment))); if (*ptr == NULL) { std::stringstream ss; ss << "realloc of size " << new_size << " failed"; + *ptr = previous_ptr; return Status::OutOfMemory(ss.str()); } #else