Browse Source

* fix overflow

peter 21 years ago
parent
commit
9e0fb804f1
1 changed files with 29 additions and 20 deletions
  1. 29 20
      compiler/ncgcon.pas

+ 29 - 20
compiler/ncgcon.pas

@@ -67,7 +67,7 @@ implementation
       verbose,globals,
       verbose,globals,
       symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
       symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
       cpuinfo,cpubase,
       cpuinfo,cpubase,
-      cgbase,tgobj,cgobj
+      cgbase,cgobj
 {$ifdef delphi}
 {$ifdef delphi}
       ,dmisc
       ,dmisc
 {$endif}
 {$endif}
@@ -268,15 +268,18 @@ implementation
                                          begin
                                          begin
                                            j:=1;
                                            j:=1;
                                            same_string:=true;
                                            same_string:=true;
-                                           for i:=0 to len-1 do
-                                            begin
-                                              if tai_string(hp1).str[j]<>value_str[i] then
-                                               begin
-                                                 same_string:=false;
-                                                 break;
-                                               end;
-                                              inc(j);
-                                            end;
+                                           if len>0 then
+                                             begin
+                                               for i:=0 to len-1 do
+                                                begin
+                                                  if tai_string(hp1).str[j]<>value_str[i] then
+                                                   begin
+                                                     same_string:=false;
+                                                     break;
+                                                   end;
+                                                  inc(j);
+                                                end;
+                                             end;
                                          end;
                                          end;
                                      end;
                                      end;
                                    st_ansistring,
                                    st_ansistring,
@@ -308,15 +311,18 @@ implementation
                                            lastlabel:=tai_label(hp2.previous.previous.previous.previous).l;
                                            lastlabel:=tai_label(hp2.previous.previous.previous.previous).l;
                                            same_string:=true;
                                            same_string:=true;
                                            j:=0;
                                            j:=0;
-                                           for i:=0 to len-1 do
-                                            begin
-                                              if tai_string(hp1).str[j]<>value_str[i] then
-                                               begin
-                                                 same_string:=false;
-                                                 break;
-                                               end;
-                                              inc(j);
-                                            end;
+                                           if len>0 then
+                                             begin
+                                               for i:=0 to len-1 do
+                                                begin
+                                                  if tai_string(hp1).str[j]<>value_str[i] then
+                                                   begin
+                                                     same_string:=false;
+                                                     break;
+                                                   end;
+                                                  inc(j);
+                                                end;
+                                             end;
                                          end;
                                          end;
                                      end;
                                      end;
                                  end;
                                  end;
@@ -572,7 +578,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2004-03-16 16:19:44  peter
+  Revision 1.39  2004-03-18 17:29:40  peter
+    * fix overflow
+
+  Revision 1.38  2004/03/16 16:19:44  peter
     * fix out of bounds for string compares
     * fix out of bounds for string compares
 
 
   Revision 1.37  2004/02/26 16:16:38  peter
   Revision 1.37  2004/02/26 16:16:38  peter