zhaojiahai / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Need to provide handling of invalid parameters (like null) #237

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1.

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Core\DoubleRange.cs(123): at System.Boolean 
AForge.DoubleRange.IsInside(AForge.DoubleRange range) 
      at System.Boolean AForge.DoubleRangeTest.IsInside01(AForge.DoubleRange target, AForge.DoubleRange range) 

DoubleRange s0 = new DoubleRange(0, 0);
bool b = this.IsInside01(s0, (DoubleRange)null);

2.

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Core\DoubleRange.cs(137): at System.Boolean 
AForge.DoubleRange.IsOverlapping(AForge.DoubleRange range) 
      at System.Boolean AForge.DoubleRangeTest.IsOverlapping(AForge.DoubleRange target, AForge.DoubleRange range) 

DoubleRange s0 = new DoubleRange(0, 0);
bool b = this.IsOverlapping(s0, (DoubleRange)null);

3.

System.DivideByZeroException: Attempted to divide by zero.    
D:\AForge.NET\Sources\Core\IntPoint.cs(164): at AForge.IntPoint 
AForge.IntPoint.op_Division(AForge.IntPoint p, System.Int32 factor) 
      at AForge.IntPoint AForge.IntPointTest.op_Division(AForge.IntPoint p, System.Int32 factor) 

IntPoint intPoint = this.op_Division(default(IntPoint), 0);

4.

System.OverflowException: Arithmetic operation resulted in an overflow.    
D:\AForge.NET\Sources\Core\IntPoint.cs(164): at AForge.IntPoint 
AForge.IntPoint.op_Division(AForge.IntPoint p, System.Int32 factor) 
      at AForge.IntPoint AForge.IntPointTest.op_Division(AForge.IntPoint p, System.Int32 factor) 

IntPoint s0 = default(IntPoint);
s0.X = default(int);
s0.Y = int.MinValue;
IntPoint intPoint = this.op_Division(s0, -1);

5. 

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Core\IntRange.cs(122): at System.Boolean 
AForge.IntRange.IsInside(AForge.IntRange range) 
      at System.Boolean AForge.IntRangeTest.IsInside01(AForge.IntRange target, AForge.IntRange range) 

IntRange s0 = new IntRange(0, 0);
bool b = this.IsInside01(s0, (IntRange)null);

6.

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Core\IntRange.cs(136): at System.Boolean 
AForge.IntRange.IsOverlapping(AForge.IntRange range) 
      at System.Boolean AForge.IntRangeTest.IsOverlapping(AForge.IntRange target, AForge.IntRange range) 

IntRange s0 = new IntRange(0, 0);
bool b = this.IsOverlapping(s0, (IntRange)null);

Original issue reported on code.google.com by krzysztof.blacha on 31 Jul 2011 at 7:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Please also review those

1. 

Chart chart;
chart = new Chart();
((Control)chart).Site = (ISite)null;
((Control)chart).TabIndex = 0;
disposables.Add((IDisposable)chart);
this.AddDataSeries
  (chart, (string)null, default(Color), Chart.SeriesType.Line, 0);

System.ArgumentNullException: Key cannot be null.
Parameter name: key      at System.Void 
System.Collections.Hashtable.Insert(System.Object , System.Object , 
System.Boolean ) 
      at System.Void System.Collections.Hashtable.Add(System.Object , System.Object ) 
    D:\AForge.NET\Sources\Controls\Chart.cs(339): at System.Void AForge.Controls.Chart.AddDataSeries(System.String name, System.Drawing.Color color, AForge.Controls.Chart+SeriesType type, System.Int32 width, System.Boolean updateYRange) 
    D:\AForge.NET\Sources\Controls\Chart.cs(307): at System.Void AForge.Controls.Chart.AddDataSeries(System.String name, System.Drawing.Color color, AForge.Controls.Chart+SeriesType type, System.Int32 width) 
      at System.Void AForge.Controls.ChartTest.AddDataSeries(AForge.Controls.Chart target, System.String name, System.Drawing.Color color, AForge.Controls.Chart+SeriesType type, System.Int32 width) 

2. 

Chart chart;
chart = new Chart();
((Control)chart).Site = (ISite)null;
((Control)chart).TabIndex = 0;
disposables.Add((IDisposable)chart);
this.AddDataSeries01
  (chart, (string)null, default(Color), Chart.SeriesType.Line, 0, false);

System.ArgumentNullException: Key cannot be null.
Parameter name: key      at System.Void 
System.Collections.Hashtable.Insert(System.Object , System.Object , 
System.Boolean ) 
      at System.Void System.Collections.Hashtable.Add(System.Object , System.Object ) 
    D:\AForge.NET\Sources\Controls\Chart.cs(339): at System.Void AForge.Controls.Chart.AddDataSeries(System.String name, System.Drawing.Color color, AForge.Controls.Chart+SeriesType type, System.Int32 width, System.Boolean updateYRange) 
      at System.Void AForge.Controls.ChartTest.AddDataSeries01(AForge.Controls.Chart target, System.String name, System.Drawing.Color color, AForge.Controls.Chart+SeriesType type, System.Int32 width, System.Boolean updateYRange) 

3.

Chart chart;
chart = new Chart();
((Control)chart).Site = (ISite)null;
((Control)chart).TabIndex = 0;
disposables.Add((IDisposable)chart);
this.RemoveDataSeries(chart, (string)null);

System.ArgumentNullException: Key cannot be null.
Parameter name: key      at System.Void 
System.Collections.Hashtable.Remove(System.Object ) 
    D:\AForge.NET\Sources\Controls\Chart.cs(372): at System.Void AForge.Controls.Chart.RemoveDataSeries(System.String name) 
      at System.Void AForge.Controls.ChartTest.RemoveDataSeries(AForge.Controls.Chart target, System.String name) 

4. 

Chart chart;
chart = new Chart();
((Control)chart).Site = (ISite)null;
((Control)chart).TabIndex = 0;
disposables.Add((IDisposable)chart);
this.UpdateDataSeries(chart, (string)null, (double[,])null);

System.ArgumentNullException: Key cannot be null.
Parameter name: key      at System.Object 
System.Collections.Hashtable.get_Item(System.Object key) 
    D:\AForge.NET\Sources\Controls\Chart.cs(352): at System.Void AForge.Controls.Chart.UpdateDataSeries(System.String name, System.Double[,] data) 
      at System.Void AForge.Controls.ChartTest.UpdateDataSeries(AForge.Controls.Chart target, System.String name, System.Double[,] data) 

5. 

Chart chart;
chart = new Chart();
((Control)chart).Site = (ISite)null;
((Control)chart).TabIndex = 0;
disposables.Add((IDisposable)chart);
this.UpdateDataSeries(chart, "", (double[,])null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Controls\Chart.cs(354): at System.Void 
AForge.Controls.Chart.UpdateDataSeries(System.String name, System.Double[,] 
data) 
      at System.Void AForge.Controls.ChartTest.UpdateDataSeries(AForge.Controls.Chart target, System.String name, System.Double[,] data)

Original comment by krzysztof.blacha on 31 Jul 2011 at 8:39

GoogleCodeExporter commented 8 years ago
Other issues found in Imaging.Formats

1.

FITSCodec fITSCodec;
Bitmap bitmap;
fITSCodec = new FITSCodec();
bitmap = this.DecodeSingleFrame(fITSCodec, (Stream)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\Tools.cs(74): at System.Int32 
AForge.Imaging.Formats.Tools.ReadStream(System.IO.Stream stream, System.Byte[] 
buffer, System.Int32 offset, System.Int32 count) 
    D:\AForge.NET\Sources\Imaging.Formats\FITSCodec.cs(292): at AForge.Imaging.Formats.FITSImageInfo AForge.Imaging.Formats.FITSCodec.ReadHeader(System.IO.Stream stream) 
    D:\AForge.NET\Sources\Imaging.Formats\FITSCodec.cs(198): at System.Drawing.Bitmap AForge.Imaging.Formats.FITSCodec.DecodeSingleFrame(System.IO.Stream stream) 
      at System.Drawing.Bitmap AForge.Imaging.Formats.FITSCodecTest.DecodeSingleFrame(AForge.Imaging.Formats.FITSCodec target, System.IO.Stream stream) 

2. 

FITSCodec fITSCodec;
int i;
fITSCodec = new FITSCodec();
i = this.Open(fITSCodec, (Stream)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\Tools.cs(74): at System.Int32 
AForge.Imaging.Formats.Tools.ReadStream(System.IO.Stream stream, System.Byte[] 
buffer, System.Int32 offset, System.Int32 count) 
    D:\AForge.NET\Sources\Imaging.Formats\FITSCodec.cs(292): at AForge.Imaging.Formats.FITSImageInfo AForge.Imaging.Formats.FITSCodec.ReadHeader(System.IO.Stream stream) 
    D:\AForge.NET\Sources\Imaging.Formats\FITSCodec.cs(226): at System.Int32 AForge.Imaging.Formats.FITSCodec.Open(System.IO.Stream stream) 
      at System.Int32 AForge.Imaging.Formats.FITSCodecTest.Open(AForge.Imaging.Formats.FITSCodec target, System.IO.Stream stream) 

3. 

Bitmap bitmap;
bitmap = this.DecodeFromFile((string)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(123): at 
System.Drawing.Bitmap 
AForge.Imaging.Formats.ImageDecoder.DecodeFromFile(System.String fileName, 
AForge.Imaging.Formats.ImageInfo& imageInfo) 
    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(101): at System.Drawing.Bitmap AForge.Imaging.Formats.ImageDecoder.DecodeFromFile(System.String fileName) 
      at System.Drawing.Bitmap AForge.Imaging.Formats.ImageDecoderTest.DecodeFromFile(System.String fileName) 

4. 

Bitmap bitmap;
ImageInfo imageInfo = (ImageInfo)null;
bitmap = this.DecodeFromFile01((string)null, out imageInfo);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(123): at 
System.Drawing.Bitmap 
AForge.Imaging.Formats.ImageDecoder.DecodeFromFile(System.String fileName, 
AForge.Imaging.Formats.ImageInfo& imageInfo) 
      at System.Drawing.Bitmap AForge.Imaging.Formats.ImageDecoderTest.DecodeFromFile01(System.String fileName, AForge.Imaging.Formats.ImageInfo& imageInfo) 

5. 

this.RegisterDecoder((string)null, (IImageDecoder)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(80): at 
System.Void AForge.Imaging.Formats.ImageDecoder.RegisterDecoder(System.String 
fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 
      at System.Void AForge.Imaging.Formats.ImageDecoderTest.RegisterDecoder(System.String fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 

6. 

this.RegisterDecoder("\0", (IImageDecoder)null);

System.ArgumentException: An item with the same key has already been added.     
 at System.Void 
System.ThrowHelper.ThrowArgumentException(System.ExceptionResource resource) 
      at System.Void System.Collections.Generic.Dictionary`2.Insert(!0 , !1 , System.Boolean ) 
      at System.Void System.Collections.Generic.Dictionary`2.Add(!0 , !1 ) 
    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(80): at System.Void AForge.Imaging.Formats.ImageDecoder.RegisterDecoder(System.String fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 
      at System.Void AForge.Imaging.Formats.ImageDecoderTest.RegisterDecoder(System.String fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 

7. 

this.RegisterDecoder("W", (IImageDecoder)null);

System.ArgumentException: An item with the same key has already been added.     
 at System.Void 
System.ThrowHelper.ThrowArgumentException(System.ExceptionResource resource) 
      at System.Void System.Collections.Generic.Dictionary`2.Insert(!0 , !1 , System.Boolean ) 
      at System.Void System.Collections.Generic.Dictionary`2.Add(!0 , !1 ) 
    D:\AForge.NET\Sources\Imaging.Formats\ImageDecoder.cs(80): at System.Void AForge.Imaging.Formats.ImageDecoder.RegisterDecoder(System.String fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 
      at System.Void AForge.Imaging.Formats.ImageDecoderTest.RegisterDecoder(System.String fileExtension, AForge.Imaging.Formats.IImageDecoder decoder) 

8. 

PNMCodec pNMCodec;
Bitmap bitmap;
pNMCodec = new PNMCodec();
bitmap = this.DecodeSingleFrame(pNMCodec, (Stream)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\PNMCodec.cs(212): at 
AForge.Imaging.Formats.PNMImageInfo 
AForge.Imaging.Formats.PNMCodec.ReadHeader(System.IO.Stream stream) 
    D:\AForge.NET\Sources\Imaging.Formats\PNMCodec.cs(132): at System.Drawing.Bitmap AForge.Imaging.Formats.PNMCodec.DecodeSingleFrame(System.IO.Stream stream) 
      at System.Drawing.Bitmap AForge.Imaging.Formats.PNMCodecTest.DecodeSingleFrame(AForge.Imaging.Formats.PNMCodec target, System.IO.Stream stream) 

9. 

PNMCodec pNMCodec;
int i;
pNMCodec = new PNMCodec();
i = this.Open(pNMCodec, (Stream)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging.Formats\PNMCodec.cs(212): at 
AForge.Imaging.Formats.PNMImageInfo 
AForge.Imaging.Formats.PNMCodec.ReadHeader(System.IO.Stream stream) 
    D:\AForge.NET\Sources\Imaging.Formats\PNMCodec.cs(154): at System.Int32 AForge.Imaging.Formats.PNMCodec.Open(System.IO.Stream stream) 
      at System.Int32 AForge.Imaging.Formats.PNMCodecTest.Open(AForge.Imaging.Formats.PNMCodec target, System.IO.Stream stream) 

Original comment by krzysztof.blacha on 31 Jul 2011 at 8:41

GoogleCodeExporter commented 8 years ago
Issues found inside Imaging project

1.

BlobCounter blobCounter;
blobCounter = this.Constructor01((Bitmap)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(364): at 
System.Void AForge.Imaging.BlobCounterBase.ProcessImage(System.Drawing.Bitmap 
image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(320): at System.Void AForge.Imaging.BlobCounterBase..ctor(System.Drawing.Bitmap image) 
    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(95): at System.Void AForge.Imaging.BlobCounter..ctor(System.Drawing.Bitmap image) 
      at AForge.Imaging.BlobCounter AForge.Imaging.BlobCounterTest.Constructor01(System.Drawing.Bitmap image) 

2. 

BitmapData bitmapData;
BlobCounter blobCounter;
bitmapData = new BitmapData();
bitmapData.Width = 453119050;
bitmapData.Height = 1346486376;
bitmapData.Stride = 0;
bitmapData.PixelFormat = PixelFormat.Format24bppRgb;
bitmapData.Reserved = 0;
blobCounter = this.Constructor02(bitmapData);

System.OverflowException: Arithmetic operation resulted in an overflow.    
D:\AForge.NET\Sources\Imaging\BlobCounter.cs(141): at System.Void 
AForge.Imaging.BlobCounter.BuildObjectsMap(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(412): at System.Void AForge.Imaging.BlobCounterBase.ProcessImage(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(393): at System.Void AForge.Imaging.BlobCounterBase.ProcessImage(System.Drawing.Imaging.BitmapData imageData) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(334): at System.Void AForge.Imaging.BlobCounterBase..ctor(System.Drawing.Imaging.BitmapData imageData) 
    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(103): at System.Void AForge.Imaging.BlobCounter..ctor(System.Drawing.Imaging.BitmapData imageData) 
      at AForge.Imaging.BlobCounter AForge.Imaging.BlobCounterTest.Constructor02(System.Drawing.Imaging.BitmapData imageData) 

3. 

BitmapData bitmapData;
BlobCounter blobCounter;
bitmapData = new BitmapData();
bitmapData.Width = 0;
bitmapData.Height = -5;
bitmapData.Stride = 0;
bitmapData.PixelFormat = PixelFormat.Format24bppRgb;
bitmapData.Reserved = 0;
blobCounter = this.Constructor02(bitmapData);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(345): at System.Void 
AForge.Imaging.BlobCounter.BuildObjectsMap(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(412): at System.Void AForge.Imaging.BlobCounterBase.ProcessImage(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(393): at System.Void AForge.Imaging.BlobCounterBase.ProcessImage(System.Drawing.Imaging.BitmapData imageData) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(334): at System.Void AForge.Imaging.BlobCounterBase..ctor(System.Drawing.Imaging.BitmapData imageData) 
    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(103): at System.Void AForge.Imaging.BlobCounter..ctor(System.Drawing.Imaging.BitmapData imageData) 
      at AForge.Imaging.BlobCounter AForge.Imaging.BlobCounterTest.Constructor02(System.Drawing.Imaging.BitmapData imageData) 

4.

BlobCounter blobCounter;
blobCounter = this.Constructor03((UnmanagedImage)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(408): at 
System.Void 
AForge.Imaging.BlobCounterBase.ProcessImage(AForge.Imaging.UnmanagedImage 
image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(348): at System.Void AForge.Imaging.BlobCounterBase..ctor(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(111): at System.Void AForge.Imaging.BlobCounter..ctor(AForge.Imaging.UnmanagedImage image) 
      at AForge.Imaging.BlobCounter AForge.Imaging.BlobCounterTest.Constructor03(AForge.Imaging.UnmanagedImage image) 

5.

BitmapData bitmapData;
UnmanagedImage unmanagedImage;
BlobCounter blobCounter;
bitmapData = new BitmapData();
bitmapData.Width = 528748033;
bitmapData.Height = -214450472;
bitmapData.Stride = 0;
bitmapData.PixelFormat = PixelFormat.Format24bppRgb;
bitmapData.Reserved = 0;
unmanagedImage = new UnmanagedImage(bitmapData);
blobCounter = this.Constructor03(unmanagedImage);

System.OverflowException: Arithmetic operation resulted in an overflow.    
D:\AForge.NET\Sources\Imaging\BlobCounter.cs(141): at System.Void 
AForge.Imaging.BlobCounter.BuildObjectsMap(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(412): at System.Void AForge.Imaging.BlobCounterBase.ProcessImage(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounterBase.cs(348): at System.Void AForge.Imaging.BlobCounterBase..ctor(AForge.Imaging.UnmanagedImage image) 
    D:\AForge.NET\Sources\Imaging\BlobCounter.cs(111): at System.Void AForge.Imaging.BlobCounter..ctor(AForge.Imaging.UnmanagedImage image) 
      at AForge.Imaging.BlobCounter AForge.Imaging.BlobCounterTest.Constructor03(AForge.Imaging.UnmanagedImage image) 

6.

ComplexImage complexImage;
complexImage = this.FromBitmap((Bitmap)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\ComplexImage.cs(148): at 
AForge.Imaging.ComplexImage 
AForge.Imaging.ComplexImage.FromBitmap(System.Drawing.Bitmap image) 
      at AForge.Imaging.ComplexImage AForge.Imaging.ComplexImageTest.FromBitmap(System.Drawing.Bitmap image) 

7. 

ComplexImage complexImage;
complexImage = this.FromBitmap01((BitmapData)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\ComplexImage.cs(187): at 
AForge.Imaging.ComplexImage 
AForge.Imaging.ComplexImage.FromBitmap(System.Drawing.Imaging.BitmapData 
imageData) 
      at AForge.Imaging.ComplexImage AForge.Imaging.ComplexImageTest.FromBitmap01(System.Drawing.Imaging.BitmapData imageData) 

8.

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d = this.GetSkewAngle(documentSkewChecker, (Bitmap)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(186): at 
System.Double 
AForge.Imaging.DocumentSkewChecker.GetSkewAngle(System.Drawing.Bitmap image) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle(AForge.Imaging.DocumentSkewChecker target, System.Drawing.Bitmap image) 

9.    

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d = this.GetSkewAngle01(documentSkewChecker, (Bitmap)null, default(Rectangle));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(205): at 
System.Double 
AForge.Imaging.DocumentSkewChecker.GetSkewAngle(System.Drawing.Bitmap image, 
System.Drawing.Rectangle rect) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle01(AForge.Imaging.DocumentSkewChecker target, System.Drawing.Bitmap image, System.Drawing.Rectangle rect) 

10. 

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d = this.GetSkewAngle02(documentSkewChecker, (BitmapData)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\UnmanagedImage.cs(151): at System.Void 
AForge.Imaging.UnmanagedImage..ctor(System.Drawing.Imaging.BitmapData 
bitmapData) 
    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(244): at System.Double AForge.Imaging.DocumentSkewChecker.GetSkewAngle(System.Drawing.Imaging.BitmapData imageData) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle02(AForge.Imaging.DocumentSkewChecker target, System.Drawing.Imaging.BitmapData imageData) 

11. 

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d =
  this.GetSkewAngle03(documentSkewChecker, (BitmapData)null, default(Rectangle));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\UnmanagedImage.cs(151): at System.Void 
AForge.Imaging.UnmanagedImage..ctor(System.Drawing.Imaging.BitmapData 
bitmapData) 
    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(263): at System.Double AForge.Imaging.DocumentSkewChecker.GetSkewAngle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rect) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle03(AForge.Imaging.DocumentSkewChecker target, System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rect) 

12. 

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d =
  this.GetSkewAngle03(documentSkewChecker, (BitmapData)null, default(Rectangle));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\UnmanagedImage.cs(151): at System.Void 
AForge.Imaging.UnmanagedImage..ctor(System.Drawing.Imaging.BitmapData 
bitmapData) 
    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(263): at System.Double AForge.Imaging.DocumentSkewChecker.GetSkewAngle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rect) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle03(AForge.Imaging.DocumentSkewChecker target, System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rect) 

13. 

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d = this.GetSkewAngle04(documentSkewChecker, (UnmanagedImage)null);

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(279): at 
System.Double 
AForge.Imaging.DocumentSkewChecker.GetSkewAngle(AForge.Imaging.UnmanagedImage 
image) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle04(AForge.Imaging.DocumentSkewChecker target, AForge.Imaging.UnmanagedImage image) 

14. 

DocumentSkewChecker documentSkewChecker;
double d;
documentSkewChecker = new DocumentSkewChecker();
documentSkewChecker.LocalPeakRadius = 0;
d = this.GetSkewAngle05
        (documentSkewChecker, (UnmanagedImage)null, default(Rectangle));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\DocumentSkewChecker.cs(297): at 
System.Double 
AForge.Imaging.DocumentSkewChecker.GetSkewAngle(AForge.Imaging.UnmanagedImage 
image, System.Drawing.Rectangle rect) 
      at System.Double AForge.Imaging.DocumentSkewCheckerTest.GetSkewAngle05(AForge.Imaging.DocumentSkewChecker target, AForge.Imaging.UnmanagedImage image, System.Drawing.Rectangle rect) 

15. 

this.FillRectangle((BitmapData)null, default(Rectangle), default(Color));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\UnmanagedImage.cs(151): at System.Void 
AForge.Imaging.UnmanagedImage..ctor(System.Drawing.Imaging.BitmapData 
bitmapData) 
    D:\AForge.NET\Sources\Imaging\Drawing.cs(41): at System.Void AForge.Imaging.Drawing.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 
      at System.Void AForge.Imaging.DrawingTest.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 

16.

BitmapData bitmapData;
bitmapData = new BitmapData();
bitmapData.Width = 1;
bitmapData.Height = 1;
bitmapData.Stride = 0;
bitmapData.PixelFormat = PixelFormat.Format8bppIndexed;
bitmapData.Reserved = 0;
Rectangle s0 = default(Rectangle);
s0.X = default(int);
s0.Y = default(int);
s0.Width = 2;
s0.Height = 2;
this.FillRectangle(bitmapData, s0, default(Color));

System.AccessViolationException: Attempted to read or write protected memory. 
This is often an indication that other memory is corrupt.      at System.Byte* 
AForge.SystemTools.memset(System.Byte* dst, System.Int32 filler, System.Int32 
count) 
      at System.Byte* AForge.SystemTools.SetUnmanagedMemory(System.Byte* dst, System.Int32 filler, System.Int32 count) 
    D:\AForge.NET\Sources\Imaging\Drawing.cs(95): at System.Void AForge.Imaging.Drawing.FillRectangle(AForge.Imaging.UnmanagedImage image, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 
    D:\AForge.NET\Sources\Imaging\Drawing.cs(41): at System.Void AForge.Imaging.Drawing.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 
      at System.Void AForge.Imaging.DrawingTest.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 

17.

BitmapData bitmapData;
bitmapData = new BitmapData();
bitmapData.Width = 1;
bitmapData.Height = 1;
bitmapData.Stride = 0;
bitmapData.PixelFormat = PixelFormat.Format24bppRgb;
bitmapData.Reserved = 0;
Rectangle s0 = default(Rectangle);
s0.X = default(int);
s0.Y = default(int);
s0.Width = 2;
s0.Height = 2;
this.FillRectangle(bitmapData, s0, default(Color));

System.NullReferenceException: Object reference not set to an instance of an 
object.    D:\AForge.NET\Sources\Imaging\Drawing.cs(112): at System.Void 
AForge.Imaging.Drawing.FillRectangle(AForge.Imaging.UnmanagedImage image, 
System.Drawing.Rectangle rectangle, System.Drawing.Color color) 
    D:\AForge.NET\Sources\Imaging\Drawing.cs(41): at System.Void AForge.Imaging.Drawing.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 
      at System.Void AForge.Imaging.DrawingTest.FillRectangle(System.Drawing.Imaging.BitmapData imageData, System.Drawing.Rectangle rectangle, System.Drawing.Color color) 

Original comment by krzysztof.blacha on 31 Jul 2011 at 8:51

GoogleCodeExporter commented 8 years ago
Very interesting ... What do really expect in the case if you try to hack 
things and provide NULL in those places, where it is not supposed to be? Do you 
want a Null Reference Exception to be thrown by AForge.NET framework instead of 
by .NET framework?

Original comment by andrew.k...@gmail.com on 31 Jul 2011 at 8:59

GoogleCodeExporter commented 8 years ago
I used a white box testing tools to analyses AForge and found these. And yes I 
think AForge should throw more precise exceptions like "parameter cannot be 
null". As you said there are almost same approaches to crash AForge and could 
be treated as not useful. But shouldn't AForge be prepared for bad input and 
react on it?

Original comment by krzysztof.blacha on 1 Aug 2011 at 4:00

GoogleCodeExporter commented 8 years ago
>> But shouldn't AForge be prepared for bad input and react on it?
Yes. But reaction will be the same - NullReferenceException thrown by 
AForge.NET framework or ArgumentException.

Original comment by andrew.k...@gmail.com on 1 Aug 2011 at 8:15

GoogleCodeExporter commented 8 years ago
Also you may find same type of issues in other versions. So the issue title is 
quite confusing ...

Original comment by andrew.k...@gmail.com on 1 Aug 2011 at 8:16

GoogleCodeExporter commented 8 years ago
>> Yes. But reaction will be the same - NullReferenceException thrown by 
AForge.NET framework or ArgumentException.

I expect to get InvalidArgumentException instance with description saying what 
was set wrong instead of NullReferenceException thrown by AForge.NET or the 
framework at random location within the code.

Original comment by krzysztof.blacha on 1 Aug 2011 at 3:06

GoogleCodeExporter commented 8 years ago
I mean AF shold throw ArgumentException class instance and as for the issue 
title please rename it if you got a better one.

Original comment by krzysztof.blacha on 1 Aug 2011 at 3:13

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 3 Aug 2011 at 8:18