From fdce4788af32cb9af8d77361cfddb96249263437 Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Tue, 29 Nov 2011 20:06:18 +0000 Subject: ake string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the without-'\0' string is non-empty. This replaces the conditional code added recently that makes this case return NULL. It's easier to understand if it's simply an error to call WriteInto() in this case at all. Add DCHECK()s or conditionals as appropriate to callers in order to ensure this assertion holds. BUG=none TEST=none Review URL: http://codereview.chromium.org/8418034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112005 0039d316-1c4b-4281-b951-d872f2087c98 --- base/rand_util.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'base/rand_util.cc') diff --git a/base/rand_util.cc b/base/rand_util.cc index fcbccef..a9bc961 100644 --- a/base/rand_util.cc +++ b/base/rand_util.cc @@ -71,6 +71,7 @@ void RandBytes(void* output, size_t output_length) { } std::string RandBytesAsString(size_t length) { + DCHECK_GT(length, 0u); std::string result; RandBytes(WriteInto(&result, length + 1), length); return result; -- cgit v1.1