Kernel: Let the process argv arrays be null-terminated.

Seems like this is expected. I don't know why I thought it wasn't.
This commit is contained in:
Andreas Kling 2019-01-23 07:28:38 +01:00
parent 2bedabbd6c
commit 0ebaa35aa1

View file

@ -543,13 +543,14 @@ int Process::sys$get_arguments(int* argc, char*** argv)
char* argpage = (char*)region->linearAddress.get();
*argc = m_initial_arguments.size();
*argv = (char**)argpage;
char* bufptr = argpage + (sizeof(char*) * m_initial_arguments.size());
char* bufptr = argpage + (sizeof(char*) * (m_initial_arguments.size() + 1));
for (size_t i = 0; i < m_initial_arguments.size(); ++i) {
(*argv)[i] = bufptr;
memcpy(bufptr, m_initial_arguments[i].characters(), m_initial_arguments[i].length());
bufptr += m_initial_arguments[i].length();
*(bufptr++) = '\0';
}
(*argv)[m_initial_arguments.size()] = nullptr;
return 0;
}