From 448dd5557ecceb5c9b3c6be647d29dffe2269bad Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 3 Sep 2024 12:49:30 +0000 Subject: [PATCH] Update WalletManager_findWallets Do not free if the string returned is empty (it crashes the library) --- impls/monero.dart/lib/monero.dart | 4 +++- impls/monero.dart/lib/wownero.dart | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/impls/monero.dart/lib/monero.dart b/impls/monero.dart/lib/monero.dart index b30bd3f..da3473b 100644 --- a/impls/monero.dart/lib/monero.dart +++ b/impls/monero.dart/lib/monero.dart @@ -3595,7 +3595,9 @@ String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) { .cast(); final str = strPtr.toDartString(); calloc.free(path_); - MONERO_free(strPtr.cast()); + if (str.isNotEmpty) { + MONERO_free(strPtr.cast()); + } debugEnd?.call('MONERO_WalletManager_findWallets'); return str; } catch (e) { diff --git a/impls/monero.dart/lib/wownero.dart b/impls/monero.dart/lib/wownero.dart index 5a0a288..c94a15c 100644 --- a/impls/monero.dart/lib/wownero.dart +++ b/impls/monero.dart/lib/wownero.dart @@ -3230,7 +3230,9 @@ String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) { .cast(); final str = strPtr.toDartString(); calloc.free(path_); - WOWNERO_free(strPtr.cast()); + if (str.isNotEmpty) { + WOWNERO_free(strPtr.cast()); + } debugEnd?.call('WOWNERO_WalletManager_findWallets'); return str; } catch (e) {