浏览代码

* prevent double freeing temps containing int64-sized parameters
(mantis #19700)

git-svn-id: trunk@18053 -

Jonas Maebe 14 年之前
父节点
当前提交
da3fb5de0f
共有 3 个文件被更改,包括 32 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ncgutil.pas
  3. 26 0
      tests/webtbs/tw19700.pp

+ 1 - 0
.gitattributes

@@ -11695,6 +11695,7 @@ tests/webtbs/tw1948.pp svneol=native#text/plain
 tests/webtbs/tw1950.pp svneol=native#text/plain
 tests/webtbs/tw19548.pp svneol=native#text/pascal
 tests/webtbs/tw1964.pp svneol=native#text/plain
+tests/webtbs/tw19700.pp svneol=native#text/plain
 tests/webtbs/tw1996.pp svneol=native#text/plain
 tests/webtbs/tw2001.pp svneol=native#text/plain
 tests/webtbs/tw2002.pp svneol=native#text/plain

+ 5 - 1
compiler/ncgutil.pas

@@ -1037,7 +1037,11 @@ implementation
                       tmploc:=l;
                       location_force_mem(list,tmploc);
                       cg.a_load_loc_cgpara(list,tmploc,cgpara);
-                      location_freetemp(list,tmploc);
+                      { do not free the tmploc in case the original value was
+                        already in memory, because the caller (ncgcal) will then
+                        free it again later }
+                      if not(l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
+                        location_freetemp(list,tmploc);
                     end
                   else
 {$endif not cpu64bitalu}

+ 26 - 0
tests/webtbs/tw19700.pp

@@ -0,0 +1,26 @@
+{ %target=darwin }
+{ %norun }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+
+program Main;
+uses
+    CocoaAll;
+
+type
+    TSomeView = objcclass (NSView)
+        function canvasPointFromEvent (theEvent: NSEvent): NSPoint; message 'canvasPointFromEvent:';
+    end;
+
+function TSomeView.canvasPointFromEvent (theEvent: NSEvent): NSPoint;
+begin
+    result := convertPoint_fromView(theEvent.locationInWindow, nil);
+end;
+
+var
+    argc: LongInt;
+    argv: PPChar;
+begin
+    NSApplicationMain(argc, argv);
+end.