diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2015-12-23 10:11:23 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2015-12-23 10:30:20 +0900 |
commit | 0653b2c09c810073e5c3e60ca36bc8d56e15f19f (patch) | |
tree | d4a8fe7c4a0c076614a37f46a9e1e89873acecf7 | |
parent | 52d266db1cd1d6a965c6c5bd186ba01eeacfa1a0 (diff) | |
download | bundle-0653b2c09c810073e5c3e60ca36bc8d56e15f19f.tar.gz bundle-0653b2c09c810073e5c3e60ca36bc8d56e15f19f.tar.bz2 bundle-0653b2c09c810073e5c3e60ca36bc8d56e15f19f.zip |
Add an exceptional handlingsubmit/tizen_common/20151229.154718submit/tizen_common/20151229.144031submit/tizen_common/20151229.142028submit/tizen/20151223.023412accepted/tizen/wearable/20151223.052845accepted/tizen/tv/20151223.052824accepted/tizen/mobile/20151223.052756
- If the argc is 1, the argv[1] is invalid access.
Change-Id: I38a50c8b950cb781649d84aaab77a82fe24b7e72
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | src/bundle.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/bundle.c b/src/bundle.c index 31e09d2..0da2fea 100644 --- a/src/bundle.c +++ b/src/bundle.c @@ -843,42 +843,41 @@ int bundle_free_exported_argv(int argc, char ***argv) return BUNDLE_ERROR_NONE; } - bundle * -bundle_import_from_argv(int argc, char **argv) +bundle *bundle_import_from_argv(int argc, char **argv) { + int idx; + int type; + keyval_t *kv; + keyval_array_t *kva; + unsigned char *byte; + char *encoded_byte; + unsigned int byte_size; + bundle *b; + if (!argv) { set_last_result(BUNDLE_ERROR_INVALID_PARAMETER); return NULL; /* TC_FIX error handling for argv =NULL*/ } - bundle *b = bundle_create(); - if (!b) + b = bundle_create(); + if (!b) { + set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY); return NULL; + } - - /* - int i; - for(i=0; i<argc; i++) { - BUNDLE_LOG_PRINT("[bundle-dbg] argv[%d]='%s'\n", i, argv[i]); - } - */ + if (argc < 2) { + set_last_result(BUNDLE_ERROR_NONE); + return b; + } if (!argv[1] || strcmp(argv[1], TAG_IMPORT_EXPORT_CHECK)) { - /*BUNDLE_LOG_PRINT("\nit is not encoded");*/ - int idx; /*start idx from one as argv[1] is user given argument*/ for (idx = 1; idx + 1 < argc; idx = idx + 2) bundle_add(b, argv[idx], argv[idx + 1]); return b; } - /*BUNDLE_LOG_PRINT("\nit is encoded");*/ - int idx, type; - keyval_t *kv = NULL; - keyval_array_t *kva = NULL; - unsigned char *byte = NULL; - char *encoded_byte; - unsigned int byte_size; + /* start idx from 2 as argv[1] is encoded */ for (idx = 2; idx + 1 < argc; idx = idx + 2) { kv = NULL; @@ -912,6 +911,7 @@ bundle_import_from_argv(int argc, char **argv) free(byte); byte = NULL; } + set_last_result(BUNDLE_ERROR_NONE); return b; } |