# HG changeset patch # User sheepluva # Date 1417271908 -3600 # Node ID 3b82b4d90eb7a0fb0328cf07bd7510c821a24930 # Parent c4e86a2efc55a6a39e19023298d8be1857a855c3 make the code, which was supposed to iterate file log number (if no access) and fallback to stderr in worst case rather than segfault, actually work diff -r c4e86a2efc55 -r 3b82b4d90eb7 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Sat Nov 29 15:25:09 2014 +0100 +++ b/hedgewars/uUtils.pas Sat Nov 29 15:38:28 2014 +0100 @@ -538,9 +538,6 @@ InitCriticalSection(logMutex); {$ENDIF} {$I-} -{$IFNDEF PAS2C} - logFile:= stderr; // if everything fails, write to stderr -{$ENDIF} if (length(UserPathPrefix) > 0) then begin {$IFNDEF PAS2C} @@ -553,12 +550,20 @@ while(i < 7) do begin assign(logFile, shortstring(UserPathPrefix) + '/Logs/' + logfileBase + inttostr(i) + '.log'); + Rewrite(logFile); if IOResult = 0 then break; inc(i) end; end; - Rewrite(logFile); + +{$IFNDEF PAS2C} + if (length(UserPathPrefix) = 0) or (IOResult = 0) then + begin + logFile:= stderr; // if everything fails, write to stderr + Rewrite(logFile); + end; +{$ENDIF} {$I+} {$ENDIF}