diff options
-rwxr-xr-x | include/bundle_internal.h | 1 | ||||
-rw-r--r-- | src/bundle.c | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/include/bundle_internal.h b/include/bundle_internal.h index 633c256..cb4e7de 100755 --- a/include/bundle_internal.h +++ b/include/bundle_internal.h @@ -218,7 +218,6 @@ API bundle *bundle_decode_raw(const bundle_raw *r, const int len); * @exception BUNDLE_ERROR_OUT_OF_MEMORY Out of memory * @pre @a b is a valid bundle object. * @post @a argv is a pointer of newly allocated memory. It must be freed. - * Each item of @a argv points to the string in the bundle object @a b. If @a b is freed, @a argv will have garbage pointers. DO NOT FREE @a b BEFORE ACCESSING @a argv!! * @see bundle_import_from_argv() @code #include <bundle_internal.h> diff --git a/src/bundle.c b/src/bundle.c index dea4736..c49e6ed 100644 --- a/src/bundle.c +++ b/src/bundle.c @@ -744,7 +744,7 @@ void _iter_export_to_argv(const char *key, const int type, const keyval_t *kv, unsigned char *encoded_byte = NULL; size_t byte_len = 0; - vi->argv[vi->idx] = (char *)key; + vi->argv[vi->idx] = strdup(key); if (kv->method->encode((struct keyval_t *)kv, &byte, &byte_len) == 0) { /* TODO: encode FAILED! */ BUNDLE_EXCEPTION_PRINT("bundle: FAILED to encode keyval: %s\n", @@ -806,8 +806,8 @@ int bundle_free_exported_argv(int argc, char ***argv) if (!*argv || argc < 2) return BUNDLE_ERROR_INVALID_PARAMETER; - for (i = 3; i < argc; i += 2) - free((*argv)[i]); /* need to free value from g_base64_encode() */ + for (i = 2; i < argc; i++) + free((*argv)[i]); free(*argv); *argv = NULL; |