Module: kamailio
Branch: 5.3
Commit: 0fcfc1b3a9598cfb8e66c780fdaf453af3349b45
URL:
https://github.com/kamailio/kamailio/commit/0fcfc1b3a9598cfb8e66c780fdaf453…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-10-30T14:47:49+01:00
core: parser rr - clean partially cloned fields in case of error
(cherry picked from commit e4f6c660bd75cdb9ff0855fcb511673cc8ec00c4)
(cherry picked from commit e3cda7fa4e873c110ee2641f6200fad52222586a)
---
Modified: src/core/parser/parse_rr.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0fcfc1b3a9598cfb8e66c780fdaf453…
Patch:
https://github.com/kamailio/kamailio/commit/0fcfc1b3a9598cfb8e66c780fdaf453…
---
diff --git a/src/core/parser/parse_rr.c b/src/core/parser/parse_rr.c
index a089b895fc..9557bffc9b 100644
--- a/src/core/parser/parse_rr.c
+++ b/src/core/parser/parse_rr.c
@@ -296,7 +296,8 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
} else {
PKG_MEM_ERROR;
}
- return -2;
+ ret = -2;
+ goto error;
}
memcpy(res, it, sizeof(rr_t));
@@ -313,7 +314,8 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
LM_ERR("Error while duplicating parameters\n");
if (_shm) shm_free(res);
else pkg_free(res);
- return -3;
+ ret = -3;
+ goto error;
}
xlate_pointers(it, res);
@@ -327,6 +329,18 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
it = it->next;
}
return 0;
+
+error:
+ if(*_new != NULL) {
+ if (_shm) {
+ shm_free_rr(_new);
+ } else {
+ free_rr(_new);
+ }
+ *_new = NULL;
+ }
+
+ return ret;
}