]> git.vpit.fr Git - perl/modules/Scope-Upper.git/commitdiff
Fix some unlikely possible uninitialized reads
authorVincent Pit <vince@profvince.com>
Thu, 12 Feb 2009 20:16:12 +0000 (21:16 +0100)
committerVincent Pit <vince@profvince.com>
Thu, 12 Feb 2009 20:16:12 +0000 (21:16 +0100)
Upper.xs

index cba5d3d048b81e46ad212c51ae6714df5e89d2e5..17c4407eca2b39af44177bd1433e86133eee031c 100644 (file)
--- a/Upper.xs
+++ b/Upper.xs
@@ -641,13 +641,15 @@ STATIC void su_unwind(pTHX_ void *ud_) {
  STMT_START {                  \
   if (items > A) {             \
    SV *csv = ST(B);            \
-   if (SvOK(csv))              \
-    cxix = SvIV(csv);          \
+   if (!SvOK(csv))             \
+    goto default_cx;           \
+   cxix = SvIV(csv);           \
    if (cxix < 0)               \
     cxix = 0;                  \
    else if (cxix > cxstack_ix) \
     cxix = cxstack_ix;         \
   } else {                     \
+default_cx:                    \
    cxix = cxstack_ix;          \
    if (PL_DBsub)               \
     SU_SKIP_DB(cxix);          \
@@ -656,14 +658,15 @@ STATIC void su_unwind(pTHX_ void *ud_) {
 
 #define SU_GET_LEVEL(A, B) \
  STMT_START {              \
+  level = 0;               \
   if (items > 0) {         \
    SV *lsv = ST(B);        \
-   if (SvOK(lsv))          \
+   if (SvOK(lsv)) {        \
     level = SvIV(lsv);     \
-   if (level < 0)          \
-    level = 0;             \
-  } else                   \
-   level = 0;              \
+    if (level < 0)         \
+     level = 0;            \
+   }                       \
+  }                        \
  } STMT_END
 
 XS(XS_Scope__Upper_unwind); /* prototype to pass -Wmissing-prototypes */