From 3e26b1363ff8b39a472fc2d4fe9ee59ee818b977 Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Tue, 20 Dec 2016 14:31:28 -0800 Subject: [PATCH] GpuService: handle null shell command Test: for cmd in "" help vkjson foo; do adb shell cmd gpu $cmd; done Bug: 33747292 Change-Id: Iaed396cc5157e17bf72b53566fb3e38c64182c44 --- services/surfaceflinger/GpuService.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/services/surfaceflinger/GpuService.cpp b/services/surfaceflinger/GpuService.cpp index b993dfbb46..dc1d3f06f5 100644 --- a/services/surfaceflinger/GpuService.cpp +++ b/services/surfaceflinger/GpuService.cpp @@ -71,12 +71,15 @@ status_t GpuService::shellCommand(int /*in*/, int out, int err, for (size_t i = 0, n = args.size(); i < n; i++) ALOGV(" arg[%zu]: '%s'", i, String8(args[i]).string()); - if (args[0] == String16("vkjson")) - return cmd_vkjson(out, err); - else if (args[0] == String16("help")) - return cmd_help(out); - - return NO_ERROR; + if (args.size() >= 1) { + if (args[0] == String16("vkjson")) + return cmd_vkjson(out, err); + if (args[0] == String16("help")) + return cmd_help(out); + } + // no command, or unrecognized command + cmd_help(err); + return BAD_VALUE; } // ---------------------------------------------------------------------------- -- 2.11.0