diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-01-24 11:56:07 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2024-01-24 11:56:07 +0000 |
| commit | e90fe5ece9e76837fb438e90da77b29eff4e7456 (patch) | |
| tree | 31a13aa003996fb1c6e77c2326c48ce9f1724e6a /libbb/appletlib.c | |
| parent | 25e7fad9b5d6c4101760f9162fe1664c7f6ec363 (diff) | |
| download | busybox-w32-e90fe5ece9e76837fb438e90da77b29eff4e7456.tar.gz busybox-w32-e90fe5ece9e76837fb438e90da77b29eff4e7456.tar.bz2 busybox-w32-e90fe5ece9e76837fb438e90da77b29eff4e7456.zip | |
win32: avoid invalid free
In external_exists() in appletlib.c it's necessary to take a copy
of the pointer to the allocated variable path1 so it can be freed:
find_executable() will change its value.
Diffstat (limited to 'libbb/appletlib.c')
| -rw-r--r-- | libbb/appletlib.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index ebf24066d..5b42a9091 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
| @@ -280,10 +280,12 @@ int FAST_FUNC find_applet_by_name(const char *name) | |||
| 280 | 280 | ||
| 281 | static int external_exists(const char *name, const char *path) | 281 | static int external_exists(const char *name, const char *path) |
| 282 | { | 282 | { |
| 283 | char *path1 = xstrdup(path ?: getenv("PATH")); | 283 | char *path0, *path1, *ret; |
| 284 | char *ret = find_executable(name, &path1); | 284 | |
| 285 | path0 = path1 = xstrdup(path ?: getenv("PATH")); | ||
| 286 | ret = find_executable(name, &path1); | ||
| 285 | free(ret); | 287 | free(ret); |
| 286 | free(path1); | 288 | free(path0); |
| 287 | return ret != NULL; | 289 | return ret != NULL; |
| 288 | } | 290 | } |
| 289 | 291 | ||
