Fix out-of-range array access in gta component-split.
authorTim Landscheidt <tim@tim-landscheidt.de>
Sun, 17 Mar 2019 08:50:47 +0000 (09:50 +0100)
committerMartin Lambers <marlam@marlam.de>
Sun, 17 Mar 2019 08:50:47 +0000 (09:50 +0100)
gtatool/src/component/component-split.cpp

index 6d7ae87..a27bd89 100644 (file)
@@ -134,7 +134,7 @@ extern "C" int gtatool_component_split(int argc, char *argv[])
                         size_t out_comp_offset = 0;
                         for (uintmax_t i = 0; i < hdri.components(); i++)
                         {
-                            if (i == comp_indices[out_index])
+                            if (out_index < comp_indices.size() && i == comp_indices[out_index])
                             {
                                 tmpeloops[out_index].write(static_cast<const char *>(element) + out_comp_offset);
                                 out_index++;