https://gcc.gnu.org/g:e56b72872d6daa775dd4a486c15cd85fe910c4e1

commit r16-4606-ge56b72872d6daa775dd4a486c15cd85fe910c4e1
Author: Eric Botcazou <[email protected]>
Date:   Fri Oct 24 15:38:00 2025 +0200

    Ada: Fix strange control flow in terminals.c
    
    This was caught by a static analyzer some time ago.
    
    gcc/ada/
            PR ada/98879
            * terminals.c (__gnat_setup_child_communication) [_WIN32]: Add else
            blocks in the processing of the data returned by ReadFile.

Diff:
---
 gcc/ada/terminals.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c
index 89f887556c07..85a5c0dcbd95 100644
--- a/gcc/ada/terminals.c
+++ b/gcc/ada/terminals.c
@@ -724,13 +724,16 @@ __gnat_setup_child_communication
     if (bRet == FALSE) {
       cpid = -1;
     }
-
-    dwRet = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
-    if (dwRet != 0) {
-      cpid = -1;
+    else {
+      dwRet = buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
+      if (dwRet != 0) {
+       cpid = -1;
+      }
+      else {
+       cpid = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24);
+      }
     }
 
-    cpid = buf[4] | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24);
     process->pid = cpid;
   }

Reply via email to