Skip to content
Snippets Groups Projects
Commit 3f98d20c authored by deuce's avatar deuce
Browse files

Fix fencepost error detected by Coverity...

Because the test to continue is *after* the loop, we can't continue
when c is the last index into lzh->son, or the code will make use of
lzh->son[sizeof(lzh->son)/sizeof(lzh->son[0])] which is outside the bounds
of the array.
parent 53a961dd
No related branches found
No related tags found
No related merge requests found
......@@ -468,7 +468,7 @@ static void lzh_update(lzh_t* lzh, short int c)
c = l;
}
} while (((c = lzh->prnt[c]) != 0) && c < (sizeof(lzh->son)/sizeof(lzh->son[0]))); /* do it until reaching the root */
} while (((c = lzh->prnt[c]) != 0) && c < ((sizeof(lzh->son)/sizeof(lzh->son[0]))-1)); /* do it until reaching the root */
}
static void lzh_encode_char(lzh_t* lzh, unsigned short c, uint8_t *outbuf, int32_t *outlen)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment