Browse Source

* assume that dynamic arrays with a negative reference count are immutable (at least regarding their metadata)

git-svn-id: trunk@39037 -
svenbarth 7 years ago
parent
commit
8606293028
1 changed files with 4 additions and 4 deletions
  1. 4 4
      rtl/inc/dynarr.inc

+ 4 - 4
rtl/inc/dynarr.inc

@@ -88,7 +88,7 @@ procedure fpc_dynarray_clear(var p : pointer;ti : pointer); [Public,Alias:'FPC_D
     if realp^.refcount=0 then
       HandleErrorAddrFrameInd(204,get_pc_addr,get_frame);
 
-    if declocked(realp^.refcount) then
+    if (realp^.refcount>0) and declocked(realp^.refcount) then
       begin
 {$ifdef VER3_0}
         ti:=aligntoptr(ti+2+PByte(ti)[1]);
@@ -115,9 +115,9 @@ procedure fpc_dynarray_incr_ref(p : pointer);[Public,Alias:'FPC_DYNARRAY_INCR_RE
 
      realp:=pdynarray(p-sizeof(tdynarray));
      if realp^.refcount=0 then
-       HandleErrorAddrFrameInd(204,get_pc_addr,get_frame);
-
-     inclocked(realp^.refcount);
+       HandleErrorAddrFrameInd(204,get_pc_addr,get_frame)
+     else if realp^.refcount>0 then
+       inclocked(realp^.refcount);
   end;
 
 { provide local access to dynarr_decr_ref for dynarr_setlength }