Skip to content

Commit

Permalink
Make sure retryCount option is range and type safe
Browse files Browse the repository at this point in the history
  • Loading branch information
SRSaunders committed Feb 12, 2024
1 parent 7d2a44b commit ab25181
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ShaderMake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct Options
bool useAPI = false;
bool slang = false;
bool noRegShifts = false;
uint32_t retryCount = 10; // default 10 retries for compilation task sub-process failures
int retryCount = 10; // default 10 retries for compilation task sub-process failures

bool Parse(int32_t argc, const char** argv);

Expand Down Expand Up @@ -162,7 +162,7 @@ map<string, vector<BlobEntry>> g_ShaderBlobs;
vector<TaskData> g_TaskData;
mutex g_TaskMutex;
atomic<uint32_t> g_ProcessedTaskCount;
atomic<uint32_t> g_TaskRetryCount;
atomic<int> g_TaskRetryCount;
atomic<bool> g_Terminate = false;
atomic<uint32_t> g_FailedTaskCount = 0;
uint32_t g_OriginalTaskCount;
Expand Down Expand Up @@ -736,6 +736,12 @@ bool Options::Parse(int32_t argc, const char** argv)
return false;
}

if (g_Options.retryCount < 0)
{
Printf(RED "ERROR: --retryCount must be greater than or equal to 0.\n");
return false;
}

// Absolute path is needed for source files to get "clickable" messages
#ifdef _WIN32
char cd[MAX_PATH];
Expand Down

0 comments on commit ab25181

Please sign in to comment.