Fix Symlink Code
This commit is contained in:
parent
4652efcd65
commit
99f33cab61
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**2.1.1**
|
||||||
|
* Fix Symlink Code
|
||||||
|
|
||||||
**2.1.0**
|
**2.1.0**
|
||||||
* Allow Binding ``Q`` Key To Item Dropping
|
* Allow Binding ``Q`` Key To Item Dropping
|
||||||
* Expose More Feature Flags
|
* Expose More Feature Flags
|
||||||
|
@ -30,11 +30,11 @@ static inline char *get_binary_directory() {
|
|||||||
if (lstat(EXE_PATH, &sb) == -1) {
|
if (lstat(EXE_PATH, &sb) == -1) {
|
||||||
ERR("Unable To Get " EXE_PATH " Symlink Size: %s", strerror(errno));
|
ERR("Unable To Get " EXE_PATH " Symlink Size: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
ssize_t path_size = sb.st_size + 1;
|
ssize_t path_size = sb.st_size;
|
||||||
if (sb.st_size == 0) {
|
if (sb.st_size <= 0) {
|
||||||
path_size = PATH_MAX;
|
path_size = PATH_MAX;
|
||||||
}
|
}
|
||||||
char *exe = (char *) malloc(path_size);
|
char *exe = (char *) malloc(path_size + 1);
|
||||||
ALLOC_CHECK(exe);
|
ALLOC_CHECK(exe);
|
||||||
// Read Link
|
// Read Link
|
||||||
ssize_t r = readlink(EXE_PATH, exe, path_size);
|
ssize_t r = readlink(EXE_PATH, exe, path_size);
|
||||||
@ -44,10 +44,10 @@ static inline char *get_binary_directory() {
|
|||||||
if (r > path_size) {
|
if (r > path_size) {
|
||||||
ERR("%s", "Size Of Symlink " EXE_PATH " Changed");
|
ERR("%s", "Size Of Symlink " EXE_PATH " Changed");
|
||||||
}
|
}
|
||||||
exe[path_size] = '\0';
|
exe[r + 1] = '\0';
|
||||||
|
|
||||||
// Chop Off Last Component
|
// Chop Off Last Component
|
||||||
for (int i = path_size - 1; i >= 0; i--) {
|
for (int i = r; i >= 0; i--) {
|
||||||
if (exe[i] == '/') {
|
if (exe[i] == '/') {
|
||||||
exe[i] = '\0';
|
exe[i] = '\0';
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user