]> git.tdb.fi Git - builder.git/commitdiff
Refuse to create an empty data pack
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:08:13 +0000 (20:08 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:08:13 +0000 (20:08 +0200)
This avoids a segfault from trying to access te front element of an
empty list.

source/datatool.cpp

index ca2f2e49aaef3738cd2bf2c12171af03d902c746..d23c00de00f8531898c7278d50db78730e88ddc0 100644 (file)
@@ -37,6 +37,8 @@ Target *DataTool::create_target(const list<Target *> &sources, const string &arg
        }
        else if(arg=="pack")
        {
+               if(sources.empty())
+                       throw invalid_argument("DataTool::create_target");
                list<FileTarget *> files;
                for(Target *t: sources)
                        files.push_back(&dynamic_cast<FileTarget &>(*t));