summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2021-02-25 21:14:22 +0100
committerSebastian Pipping <sebastian@pipping.org>2021-02-26 22:26:51 +0100
commitf0d302d4c4d6868c318a08bca9d39c335147f6f8 (patch)
tree3f53f8a9281c4b2087c0b3886af5ddc9903f5498
parent5c2de5067a2f3ab5864e41de777e10de7efdd3cc (diff)
downloaduriparser-f0d302d4c4d6868c318a08bca9d39c335147f6f8.tar.gz
UriCommon.c: Prepare RemoveDotSegmentsEx for re-use segments
-rw-r--r--src/UriCommon.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/UriCommon.c b/src/UriCommon.c
index 78c4554..861bf50 100644
--- a/src/UriCommon.c
+++ b/src/UriCommon.c
@@ -314,6 +314,8 @@ UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri,
}
} else {
URI_TYPE(PathSegment) * const anotherNextBackup = walker->next;
+ int freeWalker = URI_TRUE;
+
/* First segment */
if (walker->next != NULL) {
/* First segment of multiple -> update head
@@ -337,10 +339,12 @@ UriBool URI_FUNC(RemoveDotSegmentsEx)(URI_TYPE(Uri) * uri,
uri->pathTail = NULL;
}
- if (pathOwned && (walker->text.first != walker->text.afterLast)) {
- memory->free(memory, (URI_CHAR *)walker->text.first);
+ if (freeWalker) {
+ if (pathOwned && (walker->text.first != walker->text.afterLast)) {
+ memory->free(memory, (URI_CHAR *)walker->text.first);
+ }
+ memory->free(memory, walker);
}
- memory->free(memory, walker);
walker = anotherNextBackup;
}