[Mono-devel-list] [Patch] RReader not to rely on bounds checking

Robin Boerdijk robin_boerdijk at yahoo.com
Sun Jan 30 14:29:56 EST 2005


Hi,

I have some questions about the code...

--- Willibald Krenn <Willibald.Krenn at gmx.at> wrote:

> Hi!
> 
> As I already said I don't like RReader depending on bounds checks
> (plus 
> it's also swallowing all sorts of exceptions e.g. StackOverflow, 
> OutOfMem..), so I've done a quick patch.
> 
> Any comments? My I commit it?
> 
> Willi
> > Index:
class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
> ===================================================================
> --- class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
> (revision 39803)
> +++ class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs
> (working copy)
> @@ -388,6 +388,7 @@
>  	internal class RReader : MiniParser.IReader {
>  		private string xml; // custom remoting config file
>  		private int pos;
> +		private int len;
>  
>  		public RReader (string filename)
>  		{
> @@ -395,19 +396,17 @@
>  				StreamReader sr = new StreamReader (filename);
>  				xml = sr.ReadToEnd ();
>  				sr.Close ();
> +				len = xml.Length;

Isn't there a resource leak here if sr.ReadToEnd() fails? Wouldn't a
"using" or "try/finally" construct be better here?

>  			}
>  			catch {
>  				xml = null;
> +				len = 0;
> +				throw;
>  			}
>  		}

What is the use of this catch block?

Robin.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Mono-devel-list mailing list