delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/11/25/20:36:19

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Date: Sat, 25 Nov 2000 20:35:29 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin-developers AT cygwin DOT com
Subject: Re: failed malloc()?
Message-ID: <20001125203529.A31025@redhat.com>
Reply-To: cygwin-developers AT cygwin DOT com
Mail-Followup-To: cygwin-developers AT cygwin DOT com
References: <20001125200651 DOT B5139 AT redhat DOT com> <Pine DOT NEB DOT 4 DOT 10 DOT 10011251713440 DOT 14159-100000 AT cesium DOT clock DOT org>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <Pine.NEB.4.10.10011251713440.14159-100000@cesium.clock.org>; from matt@use.net on Sat, Nov 25, 2000 at 05:24:31PM -0800

On Sat, Nov 25, 2000 at 05:24:31PM -0800, Matt wrote:
>On Sat, 25 Nov 2000, Christopher Faylor wrote:
>
>> On Sat, Nov 25, 2000 at 03:41:59PM -0800, Matt wrote:
>> >I've started reviewing some of the winsup code and had a question as to
>> >how to most properly correct unchecked pointers. That is, I know to add a
>> >statement to check the freshly created/passed pointer, but not what to do
>> >in the instance that pointer is NULL. 
>> >
>> >Some places in the cygwin code do a system_printf() which is what I will
>> >assume is desired, but wanted to check to make sure what the
>> >standard/preferred way of handling such things is (if there is one).
>> >
>> >Here one of the sections of code I am looking at (cygcheck.c:91,92):
>> >  paths[num_paths] = (char *) malloc (maxlen + 1);
>> >  memcpy (paths[num_paths], s, maxlen);
>> 
>> Um.  That's not cygwin, that's cygcheck.  Proper programming practice would
>> be to check every single malloc and issue an error if there is a problem.
>> 
>> You can't use system_printf in this case since it isn't cygwin that you're
>> looking at.
>> 
>> It is usually a sign of some severe memory corruption if a program like
>> cygcheck isn't able to allocate its own buffers so I am not too worried
>> that there is no protection in this code.
>
>I wanted to start with something simple first, and once I got
>comfortable/proficient, moving onto cygwin itself. 
>
>What would be the preferred method to output these error messages?
>
>I am using the format "file: function: message". For example,
>"cygcheck.cc: get_word(): Readfile returned error (GetLastError)".

Look for other error messages and copy that.  Finding usage of 'stderr'
would be one way to start.

cgf

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019