[sr-dev] git:5.2:d86c831a: core: str2int() test first if result is null, otherwise init it to 0

Daniel-Constantin Mierla miconda at gmail.com
Mon Oct 7 11:44:44 CEST 2019


Module: kamailio
Branch: 5.2
Commit: d86c831a474e57acc6bd744eb52a24b3b7b9a3c0
URL: https://github.com/kamailio/kamailio/commit/d86c831a474e57acc6bd744eb52a24b3b7b9a3c0

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-10-07T11:43:55+02:00

core: str2int() test first if result is null, otherwise init it to 0

(cherry picked from commit b83a165e2d0e34c9bca742708c1891eb114bae04)
(cherry picked from commit ac16e21715e57befcba386e74214fa482bdf97d7)

---

Modified: src/core/ut.h

---

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

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 8d4f01e9a1..4a5cc463a5 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -635,12 +635,12 @@ static inline int str2int(str* _s, unsigned int* _r)
 {
 	int i;
 
-	if (_s == NULL) return -1;
 	if (_r == NULL) return -1;
+	*_r = 0;
+	if (_s == NULL) return -1;
 	if (_s->len < 0) return -1;
 	if (_s->s == NULL) return -1;
 
-	*_r = 0;
 	for(i = 0; i < _s->len; i++) {
 		if ((_s->s[i] >= '0') && (_s->s[i] <= '9')) {
 			*_r *= 10;




More information about the sr-dev mailing list