Website Summary Files Commits Branches @commit @diff @stats
path: root / util.c
diff options
context:
space:
mode:
Commit52355a5cd5e451c2bf4f969c039e529eb6245a8e (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-12-08 18:25:01 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-12-08 18:25:01 +0200
Files11044841940c0b9b320bfc61b7e80c84c06095dd /util.c
pico-web-52355a5cd5e451c2bf4f969c039e529eb6245a8e.tar
pico-web-52355a5cd5e451c2bf4f969c039e529eb6245a8e.tar.gz
pico-web-52355a5cd5e451c2bf4f969c039e529eb6245a8e.zip
Parent60a717a163c4819d61e6bd1edd77e10c1b400e44 (diff)
[browser] Fixed memory leaks and did slight reorganizing
1 files changed, 5 insertions, 2 deletions
-rw-r--r--util.c7
diff --git a/util.c b/util.c
index 8d1fa60..0d8f7c6 100644
--- a/util.c
+++ b/util.c
@@ -104,8 +104,11 @@ sds gsub_getm(sds str, const regex_t *regex, const char* repl, int* *matches, in
* repl can include matched subexpressions */
for(size_t i = 0; i < replLen; i++) {
if (repl[i] <= '\10') {
- if (pmatch[repl[i] % 10].rm_so > -1)
- ret = sdscatsds(ret, getMatch(MATCHSTART, pmatch[repl[i] % 10]));
+ if (pmatch[repl[i] % 10].rm_so > -1) {
+ sds match = getMatch(MATCHSTART, pmatch[repl[i] % 10]);
+ ret = sdscatsds(ret, match);
+ sdsfree(match);
+ }
}
else
ret = sdscatlen(ret, &repl[i], 1);