diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs
index 73f1bba3e65bcfb51aa34460fb4dfdc56a410b31..8a3702611d5a19cb431024fb0309a135850f4274 100644
--- a/src/header/stdio/mod.rs
+++ b/src/header/stdio/mod.rs
@@ -174,15 +174,19 @@ impl FILE {
     }
 
     pub fn try_set_orientation(&mut self, mode: c_int) -> c_int {
-        let mut stream = self.lock();
-        if stream.0.orientation == 0 {
-            stream.0.orientation = match mode {
+        let stream = self.lock();
+        stream.0.try_set_orientation_unlocked(mode)
+    }
+
+    pub fn try_set_orientation_unlocked(&mut self, mode: c_int) -> c_int {
+        if self.orientation == 0 {
+            self.orientation = match mode {
                 1..=i32::MAX => 1,
                 i32::MIN..=-1 => -1,
-                0 => stream.0.orientation,
+                0 => self.orientation,
             };
         }
-        stream.0.orientation
+        self.orientation
     }
 }