Преглед изворни кода

* prevent compiler crash caused by double freeing after reporting not
overloaded operator errors

git-svn-id: trunk@22833 -

Jonas Maebe пре 12 година
родитељ
комит
fd8827d379
3 измењених фајлова са 14 додато и 0 уклоњено
  1. 1 0
      .gitattributes
  2. 3 0
      compiler/htypechk.pas
  3. 10 0
      tests/test/toperatorerror.pp

+ 1 - 0
.gitattributes

@@ -11163,6 +11163,7 @@ tests/test/toperator86.pp svneol=native#text/pascal
 tests/test/toperator87.pp svneol=native#text/pascal
 tests/test/toperator88.pp svneol=native#text/pascal
 tests/test/toperator9.pp svneol=native#text/pascal
+tests/test/toperatorerror.pp svneol=native#text/plain
 tests/test/tover1.pp svneol=native#text/plain
 tests/test/tover2.pp svneol=native#text/plain
 tests/test/tover3.pp svneol=native#text/plain

+ 3 - 0
compiler/htypechk.pas

@@ -827,6 +827,7 @@ implementation
                 CGMessage(parser_e_operator_not_overloaded);
                 candidates.free;
                 ppn.free;
+                ppn:=nil;
                 exit;
               end;
 
@@ -847,6 +848,7 @@ implementation
                 CGMessage3(parser_e_operator_not_overloaded_3,ld.typename,arraytokeninfo[optoken].str,rd.typename);
                 candidates.free;
                 ppn.free;
+                ppn:=nil;
                 exit;
               end;
 
@@ -932,6 +934,7 @@ implementation
         if (cand_cnt=0) and (optoken=_NE) then
           begin
             ppn.free;
+            ppn:=nil;
             operpd:=nil;
             optoken:=_EQ;
             cand_cnt:=search_operator(optoken,true);

+ 10 - 0
tests/test/toperatorerror.pp

@@ -0,0 +1,10 @@
+{ %fail }
+
+type
+  tenum=(ea);
+var
+  p: pointer;
+  e: tenum;
+begin
+  if e<>p then ;
+end.