@@ -221,25 +221,23 @@ void operation::assign_data(reader& source) NOEXCEPT
221
221
source.invalidate ();
222
222
223
223
// An invalid source.read_bytes_raw returns nullptr.
224
- INPLACE (&data_, data_chunk, allocator, source.read_bytes_raw (size) );
224
+ const auto ptr = source.read_bytes_raw (size);
225
225
underflow_ = !source;
226
+ if (!underflow_)
227
+ {
228
+ INPLACE (&data_, data_chunk, allocator, ptr);
229
+ return ;
230
+ }
226
231
227
232
// This requires that provided stream terminates at the end of the script.
228
233
// When passing ops as part of a stream longer than the script, such as for
229
234
// a transaction, caller should apply source.set_limit(prefix_size), and
230
235
// clear the stream limit upon return. Stream invalidation and set_position
231
236
// do not alter a stream limit, it just behaves as a smaller stream buffer.
232
237
// Without a limit, source.read_bytes() below consumes the remaining stream.
233
- if (underflow_)
234
- {
235
- code_ = any_invalid;
236
- source.set_position (start);
237
-
238
- // An invalid source.read_bytes_raw returns nullptr.
239
- INPLACE (&data_, data_chunk, allocator, source.read_bytes_raw ());
240
- }
241
-
242
- // All byte vectors are deserializable, stream indicates own failure.
238
+ code_ = any_invalid;
239
+ source.set_position (start);
240
+ INPLACE (&data_, data_chunk, allocator, source.read_bytes_raw ());
243
241
}
244
242
245
243
// static/private
0 commit comments