unix: avoid segfault in uv_get_process_title
Fixes: https://github.com/libuv/libuv/issues/1359 PR-URL: https://github.com/libuv/libuv/pull/1360 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
42bf398b80
commit
f2756500ed
@ -98,7 +98,9 @@ int uv_get_process_title(char* buffer, size_t size) {
|
||||
else if (size <= process_title.len)
|
||||
return -ENOBUFS;
|
||||
|
||||
memcpy(buffer, process_title.str, process_title.len + 1);
|
||||
if (process_title.len != 0)
|
||||
memcpy(buffer, process_title.str, process_title.len + 1);
|
||||
|
||||
buffer[process_title.len] = '\0';
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user