@@ -1294,9 +1294,10 @@ amd_comgr_status_t AMDGPUCompiler::unbundle() {
1294
1294
1295
1295
// Generate random name if none provided
1296
1296
if (!strcmp (Input->Name , " " )) {
1297
- char *buf = (char *) malloc (sizeof (char ) * 30 );
1298
- sprintf (buf," comgr-bundle-%d.%s" , std::rand () % 10000 ,
1299
- FileExtension.c_str ());
1297
+ const size_t buf_size = sizeof (char ) * 30 ;
1298
+ char *buf = (char *)malloc (buf_size);
1299
+ snprintf (buf, buf_size, " comgr-bundle-%d.%s" , std::rand () % 10000 ,
1300
+ FileExtension.c_str ());
1300
1301
Input->Name = buf;
1301
1302
}
1302
1303
@@ -1419,8 +1420,9 @@ amd_comgr_status_t AMDGPUCompiler::linkBitcodeToBitcode() {
1419
1420
// string to assign. This string is used when the DataObject is written
1420
1421
// to the file system via SAVE_TEMPS, or if the object is a bundle which
1421
1422
// also needs a file system write for unpacking
1422
- char *buf = (char *) malloc (sizeof (char ) * 30 );
1423
- sprintf (buf," comgr-anon-bitcode-%d.bc" , std::rand () % 10000 );
1423
+ const size_t buf_size = sizeof (char ) * 30 ;
1424
+ char *buf = (char *)malloc (buf_size);
1425
+ snprintf (buf, buf_size, " comgr-anon-bitcode-%d.bc" , std::rand () % 10000 );
1424
1426
1425
1427
Input->Name = buf;
1426
1428
}
0 commit comments