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

Daniel-Constantin Mierla miconda at gmail.com
Fri Oct 4 09:01:04 CEST 2019


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-10-04T08:54:35+02:00

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

---

Modified: src/core/ut.h

---

Diff:  https://github.com/kamailio/kamailio/commit/b83a165e2d0e34c9bca742708c1891eb114bae04.diff
Patch: https://github.com/kamailio/kamailio/commit/b83a165e2d0e34c9bca742708c1891eb114bae04.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