diff --git a/lib/sass/environment.rb b/lib/sass/environment.rb
index <HASH>..<HASH> 100644
--- a/lib/sass/environment.rb
+++ b/lib/sass/environment.rb
@@ -68,7 +68,7 @@ module Sass
 
     # Pop a stack frame from the mixin/include stack.
     def pop_frame
-      stack.pop if stack.last[:prepared]
+      stack.pop if stack.last && stack.last[:prepared]
       stack.pop
     end
[Sass] Don't raise odd errors about #[] for stack overflows.