diff --git a/BUILD.gn b/BUILD.gn index d96d624..567fd74 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -244,6 +244,9 @@ if (defined(ohos_lite)) { "-DMKSH_UNLIMITED", "-DMKSH_BUILD_R=593", ] + + defines = [ "MKSH_OH_ADAPT" ] + ldflags = [ "-pie", "-Wl,-z,relro", diff --git a/exec.c b/exec.c index 3d35db5..06a0048 100644 --- a/exec.c +++ b/exec.c @@ -1167,6 +1167,12 @@ builtin(const char *name, int (*func) (const char **)) struct tbl * findcom(const char *name, int flags) { +#ifdef MKSH_OH_ADAPT + // fix crash for 'exec -a0' + if (name == NULL) { + return NULL; + } +#endif static struct tbl temp; uint32_t h = hash(name); struct tbl *tp = NULL, *tbi;