summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorJin Feng <jin88.feng@gmail.com>2013-06-04 11:46:24 +0200
committerJin Feng <jin88.feng@gmail.com>2013-06-04 11:46:24 +0200
commit93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8 (patch)
tree947b893bed823941f5a7fb5368d892d30bcef135 /recovery.cpp
parentMerge "minadbd: remove unnecessary header files." (diff)
downloadandroid_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar.gz
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar.bz2
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar.lz
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar.xz
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.tar.zst
android_bootable_recovery-93ffa7579cd75d1bdb2d124aa5cc5f8b6025e3d8.zip
Diffstat (limited to '')
-rw-r--r--recovery.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 92aa50372..2541e54d8 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -198,6 +198,7 @@ get_args(int *argc, char ***argv) {
if (*argc <= 1) {
FILE *fp = fopen_path(COMMAND_FILE, "r");
if (fp != NULL) {
+ char *token;
char *argv0 = (*argv)[0];
*argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
(*argv)[0] = argv0; // use the same program name
@@ -205,7 +206,12 @@ get_args(int *argc, char ***argv) {
char buf[MAX_ARG_LENGTH];
for (*argc = 1; *argc < MAX_ARGS; ++*argc) {
if (!fgets(buf, sizeof(buf), fp)) break;
- (*argv)[*argc] = strdup(strtok(buf, "\r\n")); // Strip newline.
+ token = strtok(buf, "\r\n");
+ if (token != NULL) {
+ (*argv)[*argc] = strdup(token); // Strip newline.
+ } else {
+ --*argc;
+ }
}
check_and_fclose(fp, COMMAND_FILE);