changeset 1319:69f89db51c72

Merged
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 23 Jan 2017 23:36:40 +0900
parents 2e868f71832f (diff) 2a5620128a9a (current diff)
children 949973661b25
files
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Jan 23 15:26:25 2017 +0100
+++ b/.hgtags	Mon Jan 23 23:36:40 2017 +0900
@@ -74,3 +74,7 @@
 19d01728f26f7318b5e851d3e5aae9703fa540ff 1.2.1
 9caedf4a058b5ec7274c84201bfad986bc7f943c 1.2.1a
 6446c0eea54742c8745c2efdad7963c65e74df5a 1.2.1b
+19d01728f26f7318b5e851d3e5aae9703fa540ff 1.2.1
+0000000000000000000000000000000000000000 1.2.1
+0000000000000000000000000000000000000000 1.2.1
+2cb8d71a405df19cf385e49e237f649589513e8d 1.2.1
--- a/libfdproto/dictionary.c	Mon Jan 23 15:26:25 2017 +0100
+++ b/libfdproto/dictionary.c	Mon Jan 23 23:36:40 2017 +0900
@@ -261,7 +261,7 @@
 }
 
 /* Initialize the "data" part of an object */
-static int init_object_data(struct dict_object * dest, void * source, enum dict_object_type type)
+static int init_object_data(struct dict_object * dest, void * source, enum dict_object_type type, int dupos)
 {
 	TRACE_ENTRY("%p %p %d", dest, source, type);
 	CHECK_PARAMS( dest && source && CHECK_TYPE(type) );
@@ -286,6 +286,13 @@
 			
 		case DICT_ENUMVAL:
 			DUP_string_len( dest->data.enumval.enum_name, &dest->datastr_len );
+			if (dupos) {
+				// we also need to duplicate the octetstring constant value since it is a pointer.
+				dest->data.enumval.enum_value.os.data = os0dup( 
+						((struct dict_enumval_data *)source)->enum_value.os.data, 
+						((struct dict_enumval_data *)source)->enum_value.os.len
+					);
+			}
 			break;
 
 		case DICT_AVP:
@@ -1604,6 +1611,7 @@
 int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object **ref )
 {
 	int ret = 0;
+	int dupos = 0;
 	struct dict_object * new = NULL;
 	struct dict_object * vendor = NULL;
 	struct dict_object * locref = NULL;
@@ -1654,6 +1662,12 @@
 	if (type == DICT_COMMAND) {
 		CHECK_PARAMS_DO( ((struct dict_cmd_data *)data)->cmd_flag_mask & CMD_FLAG_REQUEST, goto error_param   );
 	}
+
+	/* For ENUMVAL object, check if the parent type is an OctetString */
+	if (type == DICT_ENUMVAL) {
+		if (parent->data.type.type_base == AVP_TYPE_OCTETSTRING)
+			dupos = 1;
+	}
 	
 	/* We have to check that the new values are not equal to the sentinels */
 	if (type == DICT_VENDOR) {
@@ -1668,7 +1682,7 @@
 	
 	/* Initialize the data of the new object */
 	init_object(new, type);
-	init_object_data(new, data, type);
+	init_object_data(new, data, type, dupos);
 	new->dico = dict;
 	new->parent = parent;
 	
"Welcome to our mercurial repository"