From 9518eb255e2875ef4751951bbcc13f75af269815 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Mon, 16 Feb 2026 06:57:18 -0500 Subject: [PATCH] fix token consumption so we dont get random data at the end --- dynamodb/expression.odin | 10 ++++++++++ dynamodb/filter.odin | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dynamodb/expression.odin b/dynamodb/expression.odin index df3a870..85d974b 100644 --- a/dynamodb/expression.odin +++ b/dynamodb/expression.odin @@ -203,6 +203,16 @@ parse_key_condition_expression :: proc( sk_condition = skc } + // Verify all tokens were consumed (no trailing garbage) + if trailing := tokenizer_next(&t); trailing != nil { + delete(pk_name) + attr_value_destroy(&pk_value) + if skc, has_skc := sk_condition.?; has_skc { + skc_copy := skc + sort_key_condition_destroy(&skc_copy) + } + return + } kc = Key_Condition{ pk_name = pk_name, diff --git a/dynamodb/filter.odin b/dynamodb/filter.odin index 350fda5..823bd23 100644 --- a/dynamodb/filter.odin +++ b/dynamodb/filter.odin @@ -184,7 +184,17 @@ parse_filter_expression :: proc( ) -> (node: ^Filter_Node, ok: bool) { t := tokenizer_init(expression) node, ok = parse_or_expr(&t, attribute_names, attribute_values) - return + if !ok { + return nil, false + } + + // Verify all tokens were consumed (no trailing garbage) + if trailing := tokenizer_next(&t); trailing != nil { + filter_node_destroy(node) + return nil, false + } + + return node, true } parse_or_expr :: proc(