Browse Source

Added length checking for string reading

michael 27 years ago
parent
commit
9c5e9c2189
2 changed files with 30 additions and 7 deletions
  1. 8 1
      compiler/cg386cal.pas
  2. 22 6
      compiler/cg68k.pas

+ 8 - 1
compiler/cg386cal.pas

@@ -1565,12 +1565,16 @@ implementation
                           case pararesult^.deftype of
                           case pararesult^.deftype of
                        stringdef : begin
                        stringdef : begin
                                      if doread then
                                      if doread then
+                                       begin
+                                       { push maximum string length }
+                                       push_int(pstringdef(pararesult)^.len);
                                        case pstringdef(pararesult)^.string_typ of
                                        case pstringdef(pararesult)^.string_typ of
                                         shortstring: emitcall ('READ_TEXT_STRING',true);
                                         shortstring: emitcall ('READ_TEXT_STRING',true);
                                         ansistring : emitcall ('READ_TEXT_ANSISTRING',true);
                                         ansistring : emitcall ('READ_TEXT_ANSISTRING',true);
                                         longstring : emitcall ('READ_TEXT_LONGSTRING',true);
                                         longstring : emitcall ('READ_TEXT_LONGSTRING',true);
                                         widestring : emitcall ('READ_TEXT_ANSISTRING',true);
                                         widestring : emitcall ('READ_TEXT_ANSISTRING',true);
                                         end
                                         end
+                                       end
                                      else
                                      else
                                        Case pstringdef(Pararesult)^.string_typ of
                                        Case pstringdef(Pararesult)^.string_typ of
                                         shortstring: emitcall ('WRITE_TEXT_STRING',true);
                                         shortstring: emitcall ('WRITE_TEXT_STRING',true);
@@ -2264,7 +2268,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1998-07-06 14:19:51  michael
+  Revision 1.8  1998-07-06 15:51:15  michael
+  Added length checking for string reading
+
+  Revision 1.7  1998/07/06 14:19:51  michael
   + Added calls for reading/writing ansistrings
   + Added calls for reading/writing ansistrings
 
 
   Revision 1.6  1998/07/01 15:28:48  peter
   Revision 1.6  1998/07/01 15:28:48  peter

+ 22 - 6
compiler/cg68k.pas

@@ -3553,11 +3553,24 @@ implementation
                             end;
                             end;
                           case pararesult^.deftype of
                           case pararesult^.deftype of
                               stringdef : begin
                               stringdef : begin
-                                            if doread then
-                                              emitcall('READ_TEXT_STRING',true)
-                                            else
-                                              begin
-                                                 emitcall('WRITE_TEXT_STRING',true);
+                                          if doread then
+                                            begin
+                                            { push maximum string length }
+                                            push_int(pstringdef(pararesult)^.len);
+                                            case pstringdef(pararesult)^.string_typ of
+                                             shortstring: emitcall ('READ_TEXT_STRING',true);
+                                             ansistring : emitcall ('READ_TEXT_ANSISTRING',true);
+                                             longstring : emitcall ('READ_TEXT_LONGSTRING',true);
+                                             widestring : emitcall ('READ_TEXT_ANSISTRING',true);
+                                             end
+                                            end
+                                          else
+                                            Case pstringdef(Pararesult)^.string_typ of
+                                             shortstring: emitcall ('WRITE_TEXT_STRING',true);
+                                             ansistring : emitcall ('WRITE_TEXT_ANSISTRING',true);
+                                             longstring : emitcall ('WRITE_TEXT_LONGSTRING',true);
+                                             widestring : emitcall ('WRITE_TEXT_ANSISTRING',true);
+                                             end;
                                       {ungetiftemp(hp^.left^.location.reference);}
                                       {ungetiftemp(hp^.left^.location.reference);}
                                    end;
                                    end;
                                          end;
                                          end;
@@ -5135,7 +5148,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.8  1998-06-12 10:32:22  pierre
+  Revision 1.9  1998-07-06 15:51:16  michael
+  Added length checking for string reading
+
+  Revision 1.8  1998/06/12 10:32:22  pierre
     * column problem hopefully solved
     * column problem hopefully solved
     + C vars declaration changed
     + C vars declaration changed