Explorar o código

[LibOS] Fix an uninitialized value n in wait_event

Variable n is used without initialization.
If `if (!DkObjectsWaitAny(1, &e->event, NO_TIMEOUT))` condition is true, then code will skip the assignment of n with `n = DkStreamRead(e->event, 0, 1, &byte, NULL, 0);` and might finish the while loop. `n` should be properly initialized to prevent potential undefined behavior.

Signed-off-by: Gary <gang1.wang@intel.com>
Gary %!s(int64=5) %!d(string=hai) anos
pai
achega
5bb7180de7
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      LibOS/shim/include/shim_internal.h

+ 1 - 1
LibOS/shim/include/shim_internal.h

@@ -607,7 +607,7 @@ static inline void wait_event (AEVENTTYPE * e)
 {
     if (e->event) {
         char byte;
-        int n;
+        int n = 0;
         do {
             if (!DkObjectsWaitAny(1, &e->event, NO_TIMEOUT))
                 continue;