proc_pidpath takes a uint32_t not a size_t
authorJuan Ramos <juan@lunarg.com>
Fri, 17 Nov 2023 18:49:07 +0000 (11:49 -0700)
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>
Fri, 17 Nov 2023 19:26:21 +0000 (12:26 -0700)
loader/vk_loader_platform.h

index 08e2d301bf45dce3ae32850f355ca2e6f6279183..9e51ceb159275139bc1a2c042ab8c543110d1aec 100644 (file)
@@ -287,9 +287,15 @@ static inline char *loader_platform_executable_path(char *buffer, size_t size) {
 #if TARGET_OS_OSX
 #include <libproc.h>
 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
+    // proc_pidpath takes a uint32_t for the buffer size
+    if (size > UINT32_MAX) {
+        return NULL;
+    }
     pid_t pid = getpid();
-    int ret = proc_pidpath(pid, buffer, size);
-    if (ret <= 0) return NULL;
+    int ret = proc_pidpath(pid, buffer, (uint32_t)size);
+    if (ret <= 0) {
+        return NULL;
+    }
     buffer[ret] = '\0';
     return buffer;
 }