Browse Source

[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 5 years ago
parent
commit
5bb7180de7
1 changed files with 1 additions and 1 deletions
  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;