Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16591

Re: possible NULL && dereferencing NULL pointer

From jgk@panix.com (Joe keane)
Newsgroups comp.lang.c
Subject Re: possible NULL && dereferencing NULL pointer
Date 2012-02-01 15:15 +0000
Organization Public Access Networks Corp.
Message-ID <jgbkuc$3ra$1@reader1.panix.com> (permalink)
References <jg7srm$ka8$1@speranza.aioe.org>

Show all headers | View raw


In article <jg7srm$ka8$1@speranza.aioe.org>,
Mark <mark_cruzNOTFORSPAM@hotmail.com> wrote:
>I'm not sure that memcmp() will not fail if p_master->bridge is NULL (i.e. 
>dereferencing NULL pointer), would it be more clear and correct to have:

In general, you don't pass NULL to a function that takes 'pointer to
so-and-so object', unless you have good evidence that it's allowed, and
it does what you want.

Otherwise, it will
    a) crash,
or
    b) do not what you want.

The 'strcmp' example is good.  What does a NULL argument mean?  Is it
the same thing as the string ""?  Or are NULL and "" two different
things?  Does NULL compare equal to "NULL"?

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

possible NULL && dereferencing NULL pointer "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2012-01-31 00:05 -0500
  Re: possible NULL && dereferencing NULL pointer Devil with the China Blue Dress <chine.bleu@yahoo.com> - 2012-01-30 21:39 -0800
    Re: possible NULL && dereferencing NULL pointer Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-01-31 08:25 +0000
    Re: possible NULL && dereferencing NULL pointer Keith Thompson <kst-u@mib.org> - 2012-01-31 00:28 -0800
      Re: possible NULL && dereferencing NULL pointer Devil with the China Blue Dress <chine.bleu@yahoo.com> - 2012-01-31 00:33 -0800
        Re: possible NULL && dereferencing NULL pointer Keith Thompson <kst-u@mib.org> - 2012-01-31 02:31 -0800
          Re: possible NULL && dereferencing NULL pointer Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-31 04:54 -0800
      Re: possible NULL && dereferencing NULL pointer gwowen <gwowen@gmail.com> - 2012-01-31 02:30 -0800
        Re: possible NULL && dereferencing NULL pointer Keith Thompson <kst-u@mib.org> - 2012-01-31 13:20 -0800
  Re: possible NULL && dereferencing NULL pointer Robert Wessel <robertwessel2@yahoo.com> - 2012-01-31 01:12 -0600
  Re: possible NULL && dereferencing NULL pointer Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-31 12:33 +0000
  Re: possible NULL && dereferencing NULL pointer jgk@panix.com (Joe keane) - 2012-02-01 15:15 +0000

csiph-web