Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1442)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1454)
@@ -2901,10 +2901,12 @@
         numBits++;
       }
-      READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1");   vps->setOutputLayerSetIdx( i, uiCode + 1);
+      READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1");
     }
     else
     {
-      vps->setOutputLayerSetIdx( i, i );
-    }
+      uiCode = 0;
+    }
+
+    vps->setOutputLayerSetIdx( i, i < vps->getNumLayerSets() ? i : (uiCode + 1) );
 
     Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
@@ -3152,5 +3154,6 @@
   for( i = 1; i < vps->getNumOutputLayerSets(); i++ )
   {
-    vps->setOutputLayerSetIdx( i, i );
+    vps->setOutputLayerSetIdx( i, i < vps->getNumLayerSets() ? i : 1 );
+
     Int lsIdx = vps->getOutputLayerSetIdx(i);
 
