[sr-dev] git:master:e4f6c660: core: parser rr - clean partially cloned fields in case of error

Daniel-Constantin Mierla miconda at gmail.com
Mon Oct 26 13:37:27 CET 2020


Module: kamailio
Branch: master
Commit: e4f6c660bd75cdb9ff0855fcb511673cc8ec00c4
URL: https://github.com/kamailio/kamailio/commit/e4f6c660bd75cdb9ff0855fcb511673cc8ec00c4

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-10-26T13:36:36+01:00

core: parser rr - clean partially cloned fields in case of error

---

Modified: src/core/parser/parse_rr.c

---

Diff:  https://github.com/kamailio/kamailio/commit/e4f6c660bd75cdb9ff0855fcb511673cc8ec00c4.diff
Patch: https://github.com/kamailio/kamailio/commit/e4f6c660bd75cdb9ff0855fcb511673cc8ec00c4.patch

---

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;
 }
 
 




More information about the sr-dev mailing list