@@ -41,12 +41,12 @@ void pvt_raise_decode_error(volatile VALUE msg) {
4141int32_t pvt_validate_length (byte_buffer_t * b )
4242{
4343 int32_t length ;
44-
44+
4545 ENSURE_BSON_READ (b , 4 );
4646 memcpy (& length , READ_PTR (b ), 4 );
4747 length = BSON_UINT32_TO_LE (length );
4848
49- /* minimum valid length is 4 (byte count) + 1 (terminating byte) */
49+ /* minimum valid length is 4 (byte count) + 1 (terminating byte) */
5050 if (length >= 5 ){
5151 ENSURE_BSON_READ (b , length );
5252
@@ -59,7 +59,7 @@ int32_t pvt_validate_length(byte_buffer_t *b)
5959 else {
6060 rb_raise (rb_eRangeError , "Buffer contained invalid length %d at %zu" , length , b -> read_position );
6161 }
62-
62+
6363 return length ;
6464}
6565
@@ -175,13 +175,13 @@ VALUE pvt_get_string(byte_buffer_t *b, const char *data_type)
175175 }
176176 ENSURE_BSON_READ (b , 4 + length );
177177 str_ptr = READ_PTR (b ) + 4 ;
178- last_byte = * (READ_PTR (b ) + 4 + length_le - 1 );
178+ last_byte = * (READ_PTR (b ) + 4 + length - 1 );
179179 if (last_byte != 0 ) {
180180 pvt_raise_decode_error (rb_sprintf ("Last byte of the string is not null: 0x%x" , (int ) last_byte ));
181181 }
182182 rb_bson_utf8_validate (str_ptr , length - 1 , true, data_type );
183183 string = rb_enc_str_new (str_ptr , length - 1 , rb_utf8_encoding ());
184- b -> read_position += 4 + length_le ;
184+ b -> read_position += 4 + length ;
185185 return string ;
186186}
187187
@@ -205,7 +205,7 @@ VALUE pvt_get_symbol(byte_buffer_t *b, VALUE rb_buffer, int argc, VALUE *argv)
205205 klass = rb_funcall (rb_bson_registry , rb_intern ("get" ), 1 , INT2FIX (BSON_TYPE_SYMBOL ));
206206 value = rb_funcall (klass , rb_intern ("from_bson" ), 1 , rb_buffer );
207207 }
208-
208+
209209 RB_GC_GUARD (klass );
210210 return value ;
211211}
@@ -284,7 +284,7 @@ VALUE pvt_get_int64(byte_buffer_t *b, int argc, VALUE *argv)
284284 memcpy (& i64 , READ_PTR (b ), 8 );
285285 b -> read_position += 8 ;
286286 num = LL2NUM (BSON_UINT64_FROM_LE (i64 ));
287-
287+
288288 if (pvt_get_mode_option (argc , argv ) == BSON_MODE_BSON ) {
289289 VALUE klass = rb_funcall (rb_bson_registry ,rb_intern ("get" ),1 , INT2FIX (BSON_TYPE_INT64 ));
290290 VALUE value = rb_funcall (klass , rb_intern ("new" ), 1 , num );
@@ -293,7 +293,7 @@ VALUE pvt_get_int64(byte_buffer_t *b, int argc, VALUE *argv)
293293 } else {
294294 return num ;
295295 }
296-
296+
297297 RB_GC_GUARD (num );
298298}
299299
@@ -353,11 +353,11 @@ VALUE rb_bson_byte_buffer_get_hash(int argc, VALUE *argv, VALUE self){
353353 rb_hash_aset (doc , field , pvt_read_field (b , self , type , argc , argv ));
354354 RB_GC_GUARD (field );
355355 }
356-
356+
357357 if (READ_PTR (b ) - start_ptr != length ) {
358358 pvt_raise_decode_error (rb_sprintf ("Expected to read %d bytes for the hash but read %ld bytes" , length , READ_PTR (b ) - start_ptr ));
359359 }
360-
360+
361361 return doc ;
362362}
363363
@@ -379,10 +379,10 @@ VALUE rb_bson_byte_buffer_get_array(int argc, VALUE *argv, VALUE self){
379379 rb_ary_push (array , pvt_read_field (b , self , type , argc , argv ));
380380 }
381381 RB_GC_GUARD (array );
382-
382+
383383 if (READ_PTR (b ) - start_ptr != length ) {
384384 pvt_raise_decode_error (rb_sprintf ("Expected to read %d bytes for the hash but read %ld bytes" , length , READ_PTR (b ) - start_ptr ));
385385 }
386-
386+
387387 return array ;
388388}
0 commit comments