diff --git a/common/objects.c b/common/objects.c index 0a690b2..a9c6098 100644 --- a/common/objects.c +++ b/common/objects.c @@ -134,7 +134,8 @@ void set_area_metadata(area_t *area, const char *key, char *value, uint64_t valu newmeta->key = strdup(key); newmeta->value_length = value_length; if (dupe) { - newmeta->value = strdup(value); + newmeta->value = malloc(value_length); + memcpy(newmeta->value, value, value_length); } else { newmeta->value = value; diff --git a/linker/merge.c b/linker/merge.c index 4af7f98..52a556e 100644 --- a/linker/merge.c +++ b/linker/merge.c @@ -52,8 +52,7 @@ void relocate_area(area_t *area, uint64_t address, bool immediates) { } bool merge_areas(object_t *merged, object_t *source) { - int i; - for (i = 0; i < source->areas->length; ++i) { + for (int i = 0; i < source->areas->length; ++i) { area_t *source_area = source->areas->items[i]; area_t *merged_area = get_area_by_name(merged, source_area->name); if (merged_area == NULL) { diff --git a/scas/main.c b/scas/main.c index cf12695..589b769 100644 --- a/scas/main.c +++ b/scas/main.c @@ -280,9 +280,9 @@ int main(int argc, char **argv) { out = stdout; } else { out = fopen(scas_runtime.output_file, "w+"); - } - if (!out) { - scas_abort("Unable to open '%s' for output.", scas_runtime.output_file); + if (!out) { + scas_abort("Unable to open '%s' for output.", scas_runtime.output_file); + } } if ((scas_runtime.jobs & LINK) == LINK) {