OSDN Git Service

Fix a segfault in AudioFlinger.
authorJohn Grossman <johngro@google.com>
Thu, 9 Feb 2012 19:28:36 +0000 (11:28 -0800)
committerJohn Grossman <johngro@google.com>
Thu, 9 Feb 2012 19:31:06 +0000 (11:31 -0800)
Check the string returned by a HAL's implementation of get_parameters
for NULL before attempting to make use of it.  That way, we won't
bring down the mediaserver because of a poorly written HAL.

Change-Id: I45f0fd3de003151f98acf32c36c42f58d053f3a0

services/audioflinger/AudioFlinger.cpp

index 765d9b2..dbad3d9 100644 (file)
@@ -923,7 +923,7 @@ String8 AudioFlinger::getParameters(int ioHandle, const String8& keys)
         for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
             audio_hw_device_t *dev = mAudioHwDevs[i];
             char *s = dev->get_parameters(dev, keys.string());
-            out_s8 += String8(s);
+            out_s8 += String8(s ? s : "");
             free(s);
         }
         return out_s8;