Index: mojo/public/bindings/lib/buffer.cc |
diff --git a/mojo/public/bindings/lib/buffer.cc b/mojo/public/bindings/lib/buffer.cc |
index b5b9e7d815a4d6533686b3e9b6aca13f866c34ab..3ad964629ca1d2f1d47f3fc130e6097dc41e4fc2 100644 |
--- a/mojo/public/bindings/lib/buffer.cc |
+++ b/mojo/public/bindings/lib/buffer.cc |
@@ -34,13 +34,18 @@ ScratchBuffer::~ScratchBuffer() { |
void* ScratchBuffer::Allocate(size_t delta) { |
delta = internal::Align(delta); |
- void* result = |
- AllocateInSegment((overflow_ != NULL) ? overflow_ : &fixed_, delta); |
+ void* result = AllocateInSegment(&fixed_, delta); |
if (result) |
return result; |
+ if (overflow_) { |
+ result = AllocateInSegment(overflow_, delta); |
+ if (result) |
+ return result; |
+ } |
+ |
AddOverflowSegment(delta); |
- return Allocate(delta); |
+ return AllocateInSegment(overflow_, delta); |
} |
void* ScratchBuffer::AllocateInSegment(Segment* segment, size_t delta) { |