ext/libuv/src/unix/proctitle.c in libuv-3.2.2 vs ext/libuv/src/unix/proctitle.c in libuv-3.2.3

- old
+ new

@@ -46,18 +46,16 @@ /* Calculate how much memory we need for the argv strings. */ size = 0; for (i = 0; i < argc; i++) size += strlen(argv[i]) + 1; - process_title.str = uv__strdup(argv[0]); - if (process_title.str == NULL) - return argv; - #if defined(__MVS__) /* argv is not adjacent. So just use argv[0] */ - process_title.len = strlen(process_title.str); + process_title.str = argv[0]; + process_title.len = strlen(argv[0]); #else + process_title.str = argv[0]; process_title.len = argv[argc - 1] + strlen(argv[argc - 1]) - argv[0]; assert(process_title.len + 1 == size); /* argv memory should be adjacent. */ #endif /* Add space for the argv pointers. */ @@ -81,18 +79,14 @@ return new_argv; } int uv_set_process_title(const char* title) { - char* new_title; - /* Copy the title into our own buffer. We don't want to free the pointer - * on libuv shutdown because the program might still be using it. */ - new_title = uv__strdup(title); - if (new_title == NULL) - return -ENOMEM; - uv__free(process_title.str); - process_title.str = new_title; - process_title.len = strlen(new_title); + if (process_title.len == 0) + return 0; + + /* No need to terminate, byte after is always '\0'. */ + strncpy(process_title.str, title, process_title.len); uv__set_process_title(title); return 0; }