]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ada: Fix strange control flow in terminals.c
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 24 Oct 2025 13:38:00 +0000 (15:38 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 24 Oct 2025 16:52:45 +0000 (18:52 +0200)
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.

gcc/ada/terminals.c

index 89f887556c078920c2bd938aa32fb4b5ecf37900..85a5c0dcbd956120734e2de32615c24943d73d91 100644 (file)
@@ -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;
   }