From 2c1e37f5d5cf0152e473b73b8fc2207b895ddf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melvyn=20La=C3=AFly?= Date: Sun, 22 Apr 2018 19:31:55 +0200 Subject: [PATCH] Add more validation for the barcode parameters --- MovieBarCodeGenerator/MainForm.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MovieBarCodeGenerator/MainForm.cs b/MovieBarCodeGenerator/MainForm.cs index 921854f..ebaf1c6 100644 --- a/MovieBarCodeGenerator/MainForm.cs +++ b/MovieBarCodeGenerator/MainForm.cs @@ -252,12 +252,12 @@ 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."); } @@ -265,7 +265,7 @@ void ValidateOutputPath(ref string path) 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; }