vdc: fix segfault
Change-Id: I1a35fe15b311d3f5203c5bc02d3db87e942cf554
diff --git a/vdc.c b/vdc.c
index 0a70bf7..371f1e4 100644
--- a/vdc.c
+++ b/vdc.c
@@ -39,18 +39,20 @@
int main(int argc, char **argv) {
int sock;
int wait_for_socket;
+ char *progname;
- if (argc < 2)
- usage(argv[0]);
+ progname = argv[0];
- wait_for_socket = strcmp(argv[1], "--wait") == 0;
+ wait_for_socket = argc > 1 && strcmp(argv[1], "--wait") == 0;
if(wait_for_socket) {
argv++;
argc--;
}
- if(argc < 2)
+ if(argc < 2) {
+ usage(progname);
exit(5);
+ }
while ((sock = socket_local_client("vold",
ANDROID_SOCKET_NAMESPACE_RESERVED,