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

Scott Griepentrog asteriskteam at digium.com
Fri Aug 14 08:19:34 CDT 2015


Scott Griepentrog has uploaded a new change for review.

  https://gerrit.asterisk.org/1094

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/94/1094/1

diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index af5ae6c..5852519 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -1177,8 +1177,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/1094
To unsubscribe, visit https://gerrit.asterisk.org/settings

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



More information about the asterisk-code-review mailing list