@@ -189,8 +189,9 @@ int portability_library_path_find(const char name[], portability_library_path_st
189189
190190 if (portability_library_path_ends_with (name , "so" ) == 0 && name_dylib_length < PORTABILITY_PATH_SIZE )
191191 {
192- memcpy (path , name , sizeof (char ) * (name_length - 2 ));
193- memcpy (path , dylib_suffix , sizeof (dylib_suffix ));
192+ const size_t base_length = sizeof (char ) * (name_length - 2 );
193+ memcpy (path , name , base_length );
194+ memcpy (& path [base_length ], dylib_suffix , sizeof (dylib_suffix ));
194195 }
195196
196197 /* Start from 1 so we avoid the executable itself */
@@ -206,7 +207,7 @@ int portability_library_path_find(const char name[], portability_library_path_st
206207 printf ("Debug ends with: %s | %s\n" , image_name , name );
207208 fflush (stdout );
208209
209- if (portability_library_path_ends_with (image_name , name ) == 0 )
210+ if (portability_library_path_ends_with (image_name , path ) == 0 )
210211 {
211212 size_t image_length = strnlen (image_name , PORTABILITY_PATH_SIZE );
212213
@@ -222,7 +223,7 @@ int portability_library_path_find(const char name[], portability_library_path_st
222223 * length = image_length ;
223224 }
224225
225- printf ("Debug ended with: %s | %s => %s\n" , image_name , path , name );
226+ printf ("------------------------------- Debug ended with: %s | %s => %s\n" , image_name , path , name );
226227 fflush (stdout );
227228
228229 return 0 ;
0 commit comments