Browse Source

encoding/cbor: fix wrong allocator bug

Laytan Laats 1 year ago
parent
commit
154e0d41c6
1 changed files with 2 additions and 3 deletions
  1. 2 3
      core/encoding/cbor/coding.odin

+ 2 - 3
core/encoding/cbor/coding.odin

@@ -100,10 +100,9 @@ decode :: decode_from
 // Decodes the given string as CBOR.
 // Decodes the given string as CBOR.
 // See docs on the proc group `decode` for more information.
 // See docs on the proc group `decode` for more information.
 decode_from_string :: proc(s: string, flags: Decoder_Flags = {}, allocator := context.allocator) -> (v: Value, err: Decode_Error) {
 decode_from_string :: proc(s: string, flags: Decoder_Flags = {}, allocator := context.allocator) -> (v: Value, err: Decode_Error) {
-	context.allocator = allocator
 	r: strings.Reader
 	r: strings.Reader
 	strings.reader_init(&r, s)
 	strings.reader_init(&r, s)
-	return decode_from_reader(strings.reader_to_stream(&r), flags)
+	return decode_from_reader(strings.reader_to_stream(&r), flags, allocator)
 }
 }
 
 
 // Reads a CBOR value from the given reader.
 // Reads a CBOR value from the given reader.
@@ -489,7 +488,7 @@ _decode_text_ptr :: proc(d: Decoder, add: Add) -> (v: ^Text, err: Decode_Error)
 	return
 	return
 }
 }
 
 
-_decode_text :: proc(d: Decoder, add: Add, allocator := context.temp_allocator) -> (v: Text, err: Decode_Error) {
+_decode_text :: proc(d: Decoder, add: Add, allocator := context.allocator) -> (v: Text, err: Decode_Error) {
 	return (Text)(_decode_bytes(d, add, .Text, allocator) or_return), nil
 	return (Text)(_decode_bytes(d, add, .Text, allocator) or_return), nil
 }
 }