@@ -147,7 +147,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
147147        if  (length  >  0 ) // doesn't contain trailing NUL 
148148        {
149149            buf [length ] =  '\0' ;
150-             ffStrbufEnsureFixedLengthFree (exePath , (uint32_t )length   +   1 );  // +1 for the NUL 
150+             ffStrbufEnsureFixedLengthFree (exePath , (uint32_t )length ); 
151151            ffStrbufAppendNS (exePath , (uint32_t )length , buf );
152152        }
153153    }
@@ -193,11 +193,12 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
193193    }
194194    else 
195195    {
196-         ffStrbufEnsureFixedLengthFree ( exe ,  PATH_MAX ) ;
197-         int  length  =  proc_pidpath (pid , exe -> chars ,  exe -> allocated );
196+         char   buf [ PROC_PIDPATHINFO_MAXSIZE ] ;
197+         int  length  =  proc_pidpath (pid , buf ,  ARRAY_SIZE ( buf ) );
198198        if  (length  >  0 )
199199        {
200-             exe -> length  =  (uint32_t ) length ;
200+             ffStrbufEnsureFixedLengthFree (exe , (uint32_t ) length );
201+             ffStrbufAppendNS (exe , (uint32_t ) length , buf );
201202            if  (exePath )
202203                ffStrbufSet (exePath , exe );
203204        }
@@ -273,7 +274,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
273274        if  (length  >  0 ) // doesn't contain trailing NUL 
274275        {
275276            buf [length ] =  '\0' ;
276-             ffStrbufEnsureFixedLengthFree (exePath , (uint32_t )length   +   1 );  // +1 for the NUL 
277+             ffStrbufEnsureFixedLengthFree (exePath , (uint32_t )length ); 
277278            ffStrbufAppendNS (exePath , (uint32_t )length , buf );
278279        }
279280    }
0 commit comments