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

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


Module: kamailio
Branch: 5.3
Commit: ac16e21715e57befcba386e74214fa482bdf97d7
URL: https://github.com/kamailio/kamailio/commit/ac16e21715e57befcba386e74214fa482bdf97d7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-10-07T10:52:23+02:00

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

(cherry picked from commit b83a165e2d0e34c9bca742708c1891eb114bae04)

---

Modified: src/core/ut.h

---

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

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 88df8dba65..2259aea973 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