Browse Source

* edited fix from Rimgaudas Laucius to fix #7868

git-svn-id: trunk@5564 -
florian 18 years ago
parent
commit
a5c5c0956d
1 changed files with 6 additions and 3 deletions
  1. 6 3
      rtl/inc/wstrings.inc

+ 6 - 3
rtl/inc/wstrings.inc

@@ -237,9 +237,12 @@ Procedure fpc_WideStr_Incr_Ref(Var S : Pointer);[Public,Alias:'FPC_WIDESTR_INCR_
     If S=Nil then
       exit;
 {$ifdef FPC_WINLIKEWIDESTRING}
-    p:=s;
-    fpc_WideStr_SetLength(WideString(s),length(WideString(p)));
-    move(p^,s^,length(WideString(p))*sizeof(widechar));
+    if S<>nil then
+    begin
+      p:=NewWidestring(length(WideString(S)));
+      move(s^,p^,length(WideString(s))*sizeof(widechar));
+    end;
+    s:= p;
 {$else FPC_WINLIKEWIDESTRING}
     { Let's be paranoid : Constant string ??}
     If PWideRec(S-WideFirstOff)^.Ref<0 then exit;