Skip to content

Commit

Permalink
Add more validation for the barcode parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaily committed Apr 22, 2018
1 parent 83e1c8d commit 2c1e37f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions MovieBarCodeGenerator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,20 @@ void ValidateOutputPath(ref string path)
ValidateOutputPath(ref smoothedOutputPath);
}

if (!int.TryParse(barWidthTextBox.Text, out var barWidth))
if (!int.TryParse(barWidthTextBox.Text, out var barWidth) || barWidth <= 0)
{
throw new Exception("Invalid bar width.");
}

if (!int.TryParse(imageWidthTextBox.Text, out var imageWidth))
if (!int.TryParse(imageWidthTextBox.Text, out var imageWidth) || imageWidth <= 0)
{
throw new Exception("Invalid output width.");
}

int? imageHeight = null;
if (!useInputHeightForOutputCheckBox.Checked)
{
if (int.TryParse(imageHeightTextBox.Text, out var nonNullableImageHeight))
if (int.TryParse(imageHeightTextBox.Text, out var nonNullableImageHeight) && nonNullableImageHeight > 0)
{
imageHeight = nonNullableImageHeight;
}
Expand Down

0 comments on commit 2c1e37f

Please sign in to comment.