-
Notifications
You must be signed in to change notification settings - Fork 191
stringop-truncation and address-of-packed-member #309
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,11 @@ renditionIterate(std::function<void(Rendition const &)> const &iterator) const | |
| KeyValuePair kv = (KeyValuePair)it.second; | ||
| car_rendition_key *rendition_key = (car_rendition_key *)kv.key; | ||
| struct car_rendition_value *rendition_value = (struct car_rendition_value *)kv.value; | ||
| AttributeList attributes = AttributeList::Load(keyfmt->num_identifiers, keyfmt->identifier_list, rendition_key); | ||
| uint32_t *unpacked_identifiers = new uint32_t[sizeof(uint32_t)*keyfmt->num_identifiers]; | ||
| for(size_t i = 0; i < keyfmt->num_identifiers; ++i) { | ||
| unpacked_identifiers[i] = keyfmt->identifier_list[i]; | ||
| } | ||
| AttributeList attributes = AttributeList::Load(keyfmt->num_identifiers, unpacked_identifiers, rendition_key); | ||
| Rendition rendition = Rendition::Load(attributes, rendition_value); | ||
| iterator(rendition); | ||
| } | ||
|
|
@@ -264,7 +268,11 @@ lookupRenditions(Facet const &facet) const | |
| KeyValuePair value = (KeyValuePair)it->second; | ||
| car_rendition_key *rendition_key = (car_rendition_key *)value.key; | ||
| struct car_rendition_value *rendition_value = (struct car_rendition_value *)value.value; | ||
| AttributeList attributes = AttributeList::Load(keyfmt->num_identifiers, keyfmt->identifier_list, rendition_key); | ||
| uint32_t *unpacked_identifiers = new uint32_t[sizeof(uint32_t)*keyfmt->num_identifiers]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're never freeing the memory block you allocated here. Also, the size you allocate seems wrong to me; you're gonna end up allocating 4 entries in your array ( |
||
| for(size_t i = 0; i < keyfmt->num_identifiers; ++i) { | ||
| unpacked_identifiers[i] = keyfmt->identifier_list[i]; | ||
| } | ||
| AttributeList attributes = AttributeList::Load(keyfmt->num_identifiers, unpacked_identifiers, rendition_key); | ||
|
Comment on lines
+271
to
+275
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting. |
||
| Rendition rendition = Rendition::Load(attributes, rendition_value); | ||
| result.push_back(rendition); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ write() const | |
| return; | ||
| } | ||
|
|
||
| strncpy(header->magic, "RATC", 4); | ||
| memcpy(header->magic, "RATC", 4); | ||
| header->ui_version = 0x131; // TODO | ||
| header->storage_version = 0xC; // TODO | ||
| header->storage_timestamp = static_cast<uint32_t>(time(NULL)); // TODO | ||
|
|
@@ -127,7 +127,7 @@ write() const | |
| std::vector<enum car_attribute_identifier> format = DetermineKeyFormat(_facets, _renditions); | ||
| keyfmt_size = sizeof(struct car_key_format) + (format.size() * sizeof(uint32_t)); | ||
| keyfmt = (struct car_key_format *)malloc(keyfmt_size); | ||
| strncpy(keyfmt->magic, "tmfk", 4); | ||
| memcpy(keyfmt->magic, "tmfk", 4); | ||
| keyfmt->reserved = 0; | ||
| keyfmt->num_identifiers = format.size(); | ||
| for (size_t i = 0; i < format.size(); ++i) { | ||
|
|
@@ -162,7 +162,11 @@ write() const | |
| bom_tree_reserve(renditions_tree_context, rendition_count); | ||
| if (renditions_tree_context != NULL) { | ||
| for (auto const &item : _renditions) { | ||
| auto attributes_value = item.second.attributes().write(keyfmt->num_identifiers, keyfmt->identifier_list); | ||
| uint32_t *unpacked_identifiers = new uint32_t[sizeof(uint32_t)*keyfmt->num_identifiers]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Memory leak + incorrect size specifier. |
||
| for(size_t i = 0; i < keyfmt->num_identifiers; ++i) { | ||
| unpacked_identifiers[i] = keyfmt->identifier_list[i]; | ||
| } | ||
| auto attributes_value = item.second.attributes().write(keyfmt->num_identifiers, unpacked_identifiers); | ||
|
Comment on lines
+165
to
+169
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting. |
||
| auto rendition_value = item.second.write(); | ||
| bom_tree_add( | ||
| renditions_tree_context, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an alignment problem here.