X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Fsemihosting_common.c;h=0a60eb12118203d9a21a43445d18767c4643aeb2;hp=2df6e38aeaadbfd10dceb847770b06ff82a17004;hb=480d4e17727864f75dc60e22cb1a42e022cb1db3;hpb=70338509ca52a9b78c52a5d464ba2605fbaf193b diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index 2df6e38aea..0a60eb1211 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -877,9 +877,11 @@ int semihosting_common(struct target *target) semihosting->result = -1; semihosting->sys_errno = ENOMEM; } else { - strncpy((char *)fn, semihosting->basedir, basedir_len); - if (fn[basedir_len - 1] != '/') - fn[basedir_len++] = '/'; + if (basedir_len > 0) { + strcpy((char *)fn, semihosting->basedir); + if (fn[basedir_len - 1] != '/') + fn[basedir_len++] = '/'; + } retval = target_read_memory(target, addr, 1, len, fn + basedir_len); if (retval != ERROR_OK) { free(fn);