[libc-commits] [libc] 3983bf6 - [libc] Fix GPU argument vector writing `nullptr` to string

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Tue Aug 6 11:03:12 PDT 2024


Author: Joseph Huber
Date: 2024-08-06T13:03:06-05:00
New Revision: 3983bf6040d4a9f477290b1f43fdd1938a4261fe

URL: https://github.com/llvm/llvm-project/commit/3983bf6040d4a9f477290b1f43fdd1938a4261fe
DIFF: https://github.com/llvm/llvm-project/commit/3983bf6040d4a9f477290b1f43fdd1938a4261fe.diff

LOG: [libc] Fix GPU argument vector writing `nullptr` to string

Summary:
The intention behind this code was to null terminate the `envp` string,
but it accidentally went into the string data.

Added: 
    

Modified: 
    libc/utils/gpu/loader/Loader.h

Removed: 
    


################################################################################
diff  --git a/libc/utils/gpu/loader/Loader.h b/libc/utils/gpu/loader/Loader.h
index 2151013bae479..fd558a33b960a 100644
--- a/libc/utils/gpu/loader/Loader.h
+++ b/libc/utils/gpu/loader/Loader.h
@@ -85,7 +85,7 @@ void *copy_argument_vector(int argc, const char **argv, Allocator alloc) {
   }
 
   // Ensure the vector is null terminated.
-  reinterpret_cast<void **>(dev_argv)[argv_size] = nullptr;
+  reinterpret_cast<void **>(dev_argv)[argc + 1] = nullptr;
   return dev_argv;
 }
 


        


More information about the libc-commits mailing list