[compiler-rt] 09ab1f3 - [AIX][PGO] Add malloc error handling and deallocation to FindBinaryId function

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 12:57:51 PDT 2023


Author: Wael Yehia
Date: 2023-04-04T19:57:40Z
New Revision: 09ab1f335bce8bb4d14c28b9adad6d3bec8dfed9

URL: https://github.com/llvm/llvm-project/commit/09ab1f335bce8bb4d14c28b9adad6d3bec8dfed9
DIFF: https://github.com/llvm/llvm-project/commit/09ab1f335bce8bb4d14c28b9adad6d3bec8dfed9.diff

LOG: [AIX][PGO] Add malloc error handling and deallocation to FindBinaryId function

This is a follow up on D146976.

Reviewed By: stephenpeckham

Differential Revision: https://reviews.llvm.org/D147559

Added: 
    

Modified: 
    compiler-rt/lib/profile/InstrProfilingPlatformAIX.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
index ce03766569e1e..6e12fb9a04438 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c
@@ -38,11 +38,12 @@ static size_t FindBinaryId(char *Result, size_t Size) {
   if (RC == -1 && errno == ENOMEM) {
     BufSize = 64000; // should be plenty for any program.
     BufPtr = malloc(BufSize);
-    RC = loadquery(L_GETXINFO | L_IGNOREUNLOAD, BufPtr, (unsigned int)BufSize);
+    if (BufPtr != 0)
+      RC = loadquery(L_GETXINFO | L_IGNOREUNLOAD, BufPtr, (unsigned int)BufSize);
   }
 
   if (RC == -1)
-    return RC;
+    goto done;
 
   // Locate the ld_xinfo corresponding to this module.
   struct ld_xinfo *CurInfo = (struct ld_xinfo *)BufPtr;


        


More information about the llvm-commits mailing list