Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1dc321f

Browse files
author
Aleksander Alekseev
committed
Fix a silly bug in dict_find_match()
1 parent 02db084 commit 1dc321f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zson.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,14 @@ dict_find_match(const Dict* pdict,
200200
size_t nbytes = pdict->words[current].nbytes;
201201

202202
if(nbytes > buff_size)
203-
res = 1; // current is greater
204-
else
203+
{
204+
/* current can be less or greater depending on the prefix */
205+
res = memcmp(pdict->words[current].word, buff, buff_size);
206+
207+
/* if prefixes match, current is greater */
208+
if(res == 0)
209+
res = 1;
210+
} else
205211
res = memcmp(pdict->words[current].word, buff, nbytes);
206212

207213
if(res == 0) // match

0 commit comments

Comments
 (0)