瀏覽代碼

* fixed setting EInoutError.ErrorCode (mantis #12575, thanks to
Bart Broersma for the analysis)

git-svn-id: trunk@12037 -

Jonas Maebe 16 年之前
父節點
當前提交
dbbd75ca47
共有 3 個文件被更改,包括 26 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 8 1
      rtl/objpas/sysutils/sysutils.inc
  3. 17 0
      tests/webtbs/tw12575.pp

+ 1 - 0
.gitattributes

@@ -8613,6 +8613,7 @@ tests/webtbs/tw1250.pp svneol=native#text/plain
 tests/webtbs/tw12508a.pp svneol=native#text/plain
 tests/webtbs/tw1251b.pp svneol=native#text/plain
 tests/webtbs/tw1255.pp svneol=native#text/plain
+tests/webtbs/tw12575.pp svneol=native#text/plain
 tests/webtbs/tw1269.pp svneol=native#text/plain
 tests/webtbs/tw1275.pp svneol=native#text/plain
 tests/webtbs/tw1279.pp svneol=native#text/plain

+ 8 - 1
rtl/objpas/sysutils/sysutils.inc

@@ -284,7 +284,14 @@ begin
        106 : HS:=@SInvalidInput;
      end;
      E:=EinOutError.Create (HS^);
-     EInoutError(E).ErrorCode:=IOresult; // Clears InOutRes !!
+     // this routine can be called from FPC_IOCHECK,
+     // which clears inoutres and then passes its
+     // original value to HandleErrorFrame() (which calls
+     // us). So use errno rather than IOResult, and clear
+     // InOutRes explicitly in case we can also be called
+     // from a place that does not clear InOutRes explicitly
+     EInoutError(E).ErrorCode:=errno;
+     inoutres:=0;
      end;
   // We don't set abstracterrorhandler, but we do it here.
   // Unless the use sets another handler we'll get here anyway...

+ 17 - 0
tests/webtbs/tw12575.pp

@@ -0,0 +1,17 @@
+{$mode objfpc}
+PROGRAM Test;
+USES SysUtils;
+
+VAR
+  t : Text;
+
+BEGIN
+  Assign(t, 'blah.txt');
+  TRY
+    Close(t);
+  EXCEPT
+    ON e: EInOutError DO
+      if (e.ErrorCode <> 103) then
+        halt(1);
+  END;
+END.