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 --- media/audio/win/audio_manager_win.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'media/audio/win') diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc index 92f59d8..80d0d9d 100644 --- a/media/audio/win/audio_manager_win.cc +++ b/media/audio/win/audio_manager_win.cc @@ -211,12 +211,14 @@ string16 AudioManagerWin::GetAudioInputDeviceModel() { waveInMessage(reinterpret_cast(device_id), DRV_QUERYDEVICEINTERFACESIZE, reinterpret_cast(&device_interface_name_size), 0); - if (device_interface_name_size == 0) // No audio capture device? - return string16(); + size_t bytes_in_char16 = sizeof(string16::value_type); + DCHECK_EQ(0u, device_interface_name_size % bytes_in_char16); + if (device_interface_name_size <= bytes_in_char16) + return string16(); // No audio capture device. string16 device_interface_name; string16::value_type* name_ptr = WriteInto(&device_interface_name, - device_interface_name_size / sizeof(string16::value_type)); + device_interface_name_size / bytes_in_char16); waveInMessage(reinterpret_cast(device_id), DRV_QUERYDEVICEINTERFACE, reinterpret_cast(name_ptr), -- cgit v1.1