Skip to content

Commit

Permalink
Fix macOS issue in dlib_open()
Browse files Browse the repository at this point in the history
  • Loading branch information
frang75 committed Dec 6, 2024
1 parent 50887ca commit 393f098
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
9 changes: 5 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
### Added

- `.clang-format` file. [Issue](https://github.com/frang75/nappgui_src/issues/161). [Commit](https://github.com/frang75/nappgui_src/commit/40356b8b17a7cb1f39c2bdfa3c7d4e8ce6ef35d8).
- `arrst_insert_n0()`. [Doc](). [Commit]().
- `listbox_del_elem()`. [Doc](). [Commit]().
- `bfile_rename()`. [Doc](). [Commit]().
- `arrst_insert_n0()`. [Doc](https://nappgui.com/en/core/arrst.html#f24). [Commit](https://github.com/frang75/nappgui_src/commit/50887ca89b6a844f6b683ca1d2937f3a03cfb004).
- `listbox_del_elem()`. [Doc](https://nappgui.com/en/gui/listbox.html#f9). [Commit](https://github.com/frang75/nappgui_src/commit/50887ca89b6a844f6b683ca1d2937f3a03cfb004).
- `bfile_rename()`. [Doc](https://nappgui.com/en/osbs/bfile.html#f21). [Commit](https://github.com/frang75/nappgui_src/commit/50887ca89b6a844f6b683ca1d2937f3a03cfb004).

### Fixed

- Issue in `Layout` when window becomes very small. [Commit](https://github.com/frang75/nappgui_src/commit/3d616fa82e072b6c46f4cf196df0516912ab634c).
- Issue in `bmath_prec()`. [Commit](https://github.com/frang75/nappgui_src/commit/062d2a69ea187c2c983b0db02f022a7552295a19).
- Vulnerability in `str_upd()`. [Commit]().
- Vulnerability in `str_upd()`. [Commit](https://github.com/frang75/nappgui_src/commit/50887ca89b6a844f6b683ca1d2937f3a03cfb004).
- Issue in `dlib_open()` in macOS. [Issue](https://github.com/frang75/nappgui_src/issues/164). [Commit]().

### Improved

Expand Down
2 changes: 1 addition & 1 deletion prj/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5597
5645
31 changes: 20 additions & 11 deletions src/osbs/unix/dlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static const char_t *i_LIB_PREFIX = "lib";
static const char_t *i_LIB_SUFIX = ".so";
#elif defined(__MACOS__)
static const char_t *i_LIB_PREFIX = "lib";
static const char_t *i_LIB_SUFIX = ".so";
static const char_t *i_LIB_SUFIX = ".dylib";
#else
#error Unknown platform
#endif
Expand All @@ -32,29 +32,38 @@ static const char_t *i_LIB_SUFIX = ".so";

DLib *dlib_open(const char_t *path, const char_t *libname)
{
char_t name[512];
uint32_t size = 0;
char_t *pathname = NULL;
void *lib = NULL;

cassert_no_null(libname);
size += 2; /* Backslash and null terminator */
size += blib_strlen(libname);
size += blib_strlen(i_LIB_PREFIX);
size += blib_strlen(i_LIB_SUFIX);

if (path != NULL && path[0] != '\0')
{
uint32_t n = blib_strlen(path);
blib_strcpy(name, sizeof(name), path);
size += n;
pathname = cast(bmem_malloc(size), char_t);
blib_strcpy(pathname, size, path);
if (path[n - 1] != '/')
blib_strcat(name, sizeof(name), "/");
blib_strcat(name, sizeof(name), i_LIB_PREFIX);
blib_strcat(name, sizeof(name), libname);
blib_strcat(name, sizeof(name), i_LIB_SUFIX);
blib_strcat(pathname, size, "/");
blib_strcat(pathname, size, i_LIB_PREFIX);
blib_strcat(pathname, size, libname);
blib_strcat(pathname, size, i_LIB_SUFIX);
}
else
{
blib_strcpy(name, sizeof(name), i_LIB_PREFIX);
blib_strcat(name, sizeof(name), libname);
blib_strcat(name, sizeof(name), i_LIB_SUFIX);
pathname = cast(bmem_malloc(size), char_t);
blib_strcpy(pathname, size, i_LIB_PREFIX);
blib_strcat(pathname, size, libname);
blib_strcat(pathname, size, i_LIB_SUFIX);
}

lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL);
lib = dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
bmem_free(cast(pathname, byte_t));
if (lib != NULL)
{
_osbs_dlib_alloc();
Expand Down

0 comments on commit 393f098

Please sign in to comment.