mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
fix: SIGSEGV with env vars (#1278)
This commit is contained in:
@@ -30,16 +30,18 @@ func initPHPThreads(numThreads int) error {
|
||||
}
|
||||
phpThreads = make([]*phpThread, numThreads)
|
||||
|
||||
if err := mainThread.start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// initialize all threads as inactive
|
||||
// this needs to happen before starting the main thread
|
||||
// since some extensions access environment variables on startup
|
||||
for i := 0; i < numThreads; i++ {
|
||||
phpThreads[i] = newPHPThread(i)
|
||||
convertToInactiveThread(phpThreads[i])
|
||||
}
|
||||
|
||||
if err := mainThread.start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// start the underlying C threads
|
||||
ready := sync.WaitGroup{}
|
||||
ready.Add(numThreads)
|
||||
|
||||
@@ -73,11 +73,10 @@ func (thread *phpThread) getActiveRequest() *http.Request {
|
||||
// Pin a string that is not null-terminated
|
||||
// PHP's zend_string may contain null-bytes
|
||||
func (thread *phpThread) pinString(s string) *C.char {
|
||||
if s == "" {
|
||||
sData := unsafe.StringData(s)
|
||||
if sData == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
sData := unsafe.StringData(s)
|
||||
thread.Pin(sData)
|
||||
|
||||
return (*C.char)(unsafe.Pointer(sData))
|
||||
|
||||
Reference in New Issue
Block a user