summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 23e28fe..d98227a 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -1170,11 +1170,9 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1170 uint64_t offset_table_index = 0; 1170 uint64_t offset_table_index = 0;
1171 bytearray_t *bplist_buff = NULL; 1171 bytearray_t *bplist_buff = NULL;
1172 uint64_t i = 0; 1172 uint64_t i = 0;
1173 uint8_t *buff = NULL;
1174 uint64_t *offsets = NULL; 1173 uint64_t *offsets = NULL;
1175 bplist_trailer_t trailer; 1174 bplist_trailer_t trailer;
1176 uint64_t objects_len = 0; 1175 uint64_t objects_len = 0;
1177 uint64_t buff_len = 0;
1178 1176
1179 //check for valid input 1177 //check for valid input
1180 if (!plist || !plist_bin || *plist_bin || !length) 1178 if (!plist || !plist_bin || *plist_bin || !length)
@@ -1298,13 +1296,11 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1298 1296
1299 switch (data->type) 1297 switch (data->type)
1300 { 1298 {
1301 case PLIST_BOOLEAN: 1299 case PLIST_BOOLEAN: {
1302 buff = (uint8_t *) malloc(sizeof(uint8_t)); 1300 uint8_t b = data->boolval ? BPLIST_TRUE : BPLIST_FALSE;
1303 buff[0] = data->boolval ? BPLIST_TRUE : BPLIST_FALSE; 1301 byte_array_append(bplist_buff, &b, 1);
1304 byte_array_append(bplist_buff, buff, sizeof(uint8_t));
1305 free(buff);
1306 break; 1302 break;
1307 1303 }
1308 case PLIST_UINT: 1304 case PLIST_UINT:
1309 if (data->length == 16) { 1305 if (data->length == 16) {
1310 write_uint(bplist_buff, data->intval); 1306 write_uint(bplist_buff, data->intval);
@@ -1353,8 +1349,7 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
1353 hash_table_destroy(ref_table); 1349 hash_table_destroy(ref_table);
1354 1350
1355 //write offsets 1351 //write offsets
1356 buff_len = bplist_buff->len; 1352 offset_size = get_needed_bytes(bplist_buff->len);
1357 offset_size = get_needed_bytes(buff_len);
1358 offset_table_index = bplist_buff->len; 1353 offset_table_index = bplist_buff->len;
1359 for (i = 0; i < num_objects; i++) { 1354 for (i = 0; i < num_objects; i++) {
1360 uint64_t offset = be64toh(offsets[i]); 1355 uint64_t offset = be64toh(offsets[i]);