diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2016-05-31 15:39:07 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2016-05-31 16:59:38 +0900 |
commit | 9a3f14df29442ccc003051efc46e8ec5251a9bd4 (patch) | |
tree | b23235acedba90019dfa43d676ee85046babc0a6 | |
parent | d6bad72403d175ad22a9445ca9016729c5d30379 (diff) | |
download | bundle-9a3f14df29442ccc003051efc46e8ec5251a9bd4.tar.gz bundle-9a3f14df29442ccc003051efc46e8ec5251a9bd4.tar.bz2 bundle-9a3f14df29442ccc003051efc46e8ec5251a9bd4.zip |
Fix the bundle_export_to_argv APIsubmit/tizen/20160531.024853accepted/tizen/wearable/20160602.022740accepted/tizen/tv/20160602.022554accepted/tizen/mobile/20160602.023025accepted/tizen/ivi/20160602.022853accepted/tizen/common/20160602.140048
- Allocate memory for the keys of the bundle
Change-Id: I3daf672cfe9119c572566c44933d1d911e425b8a
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-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; |