* Android: There are cases when libc "environ" var may be NULL. Check for such case and provide fake valid environment. Bug #24519.

git-svn-id: trunk@24804 -
This commit is contained in:
yury 2013-06-04 15:21:29 +00:00
parent b7d5ed4bd7
commit 7e5af23ace
2 changed files with 16 additions and 0 deletions

View File

@ -31,6 +31,9 @@ FPC_SHARED_LIB_START:
/* Get environment info from libc */
ldr ip,=environ
ldr r0,[ip]
/* Check if environment is NULL */
cmp r0,#0
ldreq r0,=EmptyEnv
ldr ip,=operatingsystem_parameter_envp
str r0,[ip]
@ -69,6 +72,10 @@ EmptyCmdLine:
.long EmptyCmdStr
EmptyCmdStr:
.ascii "\0"
EmptyEnv:
.long 0
.long 0
.long 0
/* --------------------------------------------------------- */
.section .init_array, "aw"

View File

@ -30,6 +30,11 @@ FPC_SHARED_LIB_START:
/* Get environment info from libc */
movl environ,%eax
/* Check if environment is NULL */
cmpl %eax,0
jne env_ok
leal EmptyEnv,%eax
env_ok:
movl %eax,operatingsystem_parameter_envp
/* Register exit handler. It is called only when the main process terminates */
@ -66,6 +71,10 @@ EmptyCmdLine:
.long EmptyCmdStr
EmptyCmdStr:
.ascii "\0"
EmptyEnv:
.long 0
.long 0
.long 0
/* --------------------------------------------------------- */
.section .init_array, "aw"