Fossil SCM

Fix handling of empty-string corner case for the file_simplify_name() function.

mistachkin 2020-06-10 23:00 trunk
Commit 233a08f4fc1d5000aeea17b89adf307d2ec42bc130a52dd9ffb8c7644e79fb81
1 file changed +1
+1
--- src/file.c
+++ src/file.c
@@ -967,10 +967,11 @@
967967
*/
968968
int file_simplify_name(char *z, int n, int slash){
969969
int i = 1, j;
970970
assert( z!=0 );
971971
if( n<0 ) n = strlen(z);
972
+ if( n==0 ) return 0;
972973
973974
/* On windows and cygwin convert all \ characters to /
974975
* and remove extended path prefix if present */
975976
#if defined(_WIN32) || defined(__CYGWIN__)
976977
for(j=0; j<n; j++){
977978
--- src/file.c
+++ src/file.c
@@ -967,10 +967,11 @@
967 */
968 int file_simplify_name(char *z, int n, int slash){
969 int i = 1, j;
970 assert( z!=0 );
971 if( n<0 ) n = strlen(z);
 
972
973 /* On windows and cygwin convert all \ characters to /
974 * and remove extended path prefix if present */
975 #if defined(_WIN32) || defined(__CYGWIN__)
976 for(j=0; j<n; j++){
977
--- src/file.c
+++ src/file.c
@@ -967,10 +967,11 @@
967 */
968 int file_simplify_name(char *z, int n, int slash){
969 int i = 1, j;
970 assert( z!=0 );
971 if( n<0 ) n = strlen(z);
972 if( n==0 ) return 0;
973
974 /* On windows and cygwin convert all \ characters to /
975 * and remove extended path prefix if present */
976 #if defined(_WIN32) || defined(__CYGWIN__)
977 for(j=0; j<n; j++){
978

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button