Don't clone etc unless there are several subsets
@@ -392,6 +392,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
}
if (check_subset_number(str, numberOfSubsets, &subsetNumber) == GRIB_SUCCESS) {
+ if (numberOfSubsets > 1) {
grib_handle* new_handle = 0;
grib_handle *h2;
size_t size = 0;
@@ -410,6 +411,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
Assert(new_handle);
/* Replace handle with the new one which has only one subset */
h = new_handle; /*TODO: possible leak!*/
+ }
} else {
fprintf(stderr, "ERROR: -S option: Please specify a subset number > 0 and < %ld\n", numberOfSubsets+1);
exit(1);
