[Asterisk-code-review] CHAOS: update ast str hash to handle null ptr (asterisk[11])

Scott Griepentrog asteriskteam at digium.com
Fri Aug 14 08:28:59 CDT 2015


Scott Griepentrog has uploaded a new change for review.

  https://gerrit.asterisk.org/1095

Change subject: CHAOS: update ast_str_hash to handle null ptr
......................................................................

CHAOS: update ast_str_hash to handle null ptr

This changes ast_str_hash() to gracefully handle
a NULL str pointer.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I89677d99bffc4bbc31a30a708e7559fdfef053db
---
M include/asterisk/strings.h
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/95/1095/1

diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index aae26ab..15436fa 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -965,8 +965,11 @@
 {
 	int hash = 5381;
 
-	while (*str)
-		hash = hash * 33 ^ *str++;
+	if (str) {
+		while (*str) {
+				hash = hash * 33 ^ *str++;
+		}
+	}
 
 	return abs(hash);
 }

-- 
To view, visit https://gerrit.asterisk.org/1095
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I89677d99bffc4bbc31a30a708e7559fdfef053db
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>



More information about the asterisk-code-review mailing list