aboutsummaryrefslogtreecommitdiff
path: root/src/kmp.c
diff options
context:
space:
mode:
authorAlex Pickering <alexandermpickering@gmail.com>2019-09-28 16:06:47 -0400
committerAlex Pickering <alexandermpickering@gmail.com>2019-09-28 16:06:47 -0400
commit51aa0fd15c327c0ef20242b00b02bda169af4744 (patch)
tree707a44c28cfbbaf47916906b1ef95ecea95ac236 /src/kmp.c
parentd8987084b7aa3c47642af30a87c0673a2df01fd0 (diff)
downloadlibctemplates-51aa0fd15c327c0ef20242b00b02bda169af4744.tar.gz
libctemplates-51aa0fd15c327c0ef20242b00b02bda169af4744.tar.bz2
libctemplates-51aa0fd15c327c0ef20242b00b02bda169af4744.zip
Fixed memory corruption bugs
Fixed various memory corruption bugs in the parsing step
Diffstat (limited to 'src/kmp.c')
-rw-r--r--src/kmp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/kmp.c b/src/kmp.c
index f74dcf0..d27523c 100644
--- a/src/kmp.c
+++ b/src/kmp.c
@@ -26,6 +26,8 @@ int kmp(const char* t,size_t tlen, const char* p,size_t plen) {
while (i < n) {
if (t[i] == p[j]) {
if (j == m - 1) {
+
+ free(f);
return i - j;
}
else {
@@ -43,6 +45,7 @@ int kmp(const char* t,size_t tlen, const char* p,size_t plen) {
}
}
+ free(f);
return -1;
}