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


Groups > comp.lang.c > #16525

Re: possible NULL && dereferencing NULL pointer

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: possible NULL && dereferencing NULL pointer
Date 2012-01-31 13:20 -0800
Organization None to speak of
Message-ID <lnd39zy3fc.fsf@nuthaus.mib.org> (permalink)
References <jg7srm$ka8$1@speranza.aioe.org> <chine.bleu-B07EB1.21390330012012@news.eternal-september.org> <lnliooxolh.fsf@nuthaus.mib.org> <3599ea06-09eb-4ace-9438-4fb6d5329f7b@o12g2000vbd.googlegroups.com>

Show all headers | View raw


gwowen <gwowen@gmail.com> writes:
> On Jan 31, 8:28 am, Keith Thompson <ks...@mib.org> wrote:
>> Mark, my advice is to fix your code's logic so it doesn't try to call
>> memcpy() with null arguments.
>
> But isn't a wrapper function a not-unreasonable way to do that?
>
> I wouldn't recommend DwtCBD's particular level of clever-clever
> obfuscation, but *at the very least* it changes undefined behaviour to
> defined behaviour.

It's impossible to tell without more information.

Changing undefined behavior to defined behavior is not useful if the
defined behavior is logically incorrect.

A wrapper around memcpy() that checks for null pointer arguments and
does something reasonable *might* be a good idea.  But if the presence
of null pointers indicates a logical flaw in the code, then there is no
reasonable action to take (except perhaps to terminate the program with
an error message).  In that case, the correct solution would be to fix
the program so it doesn't encounter that situation in the first place.

Without more information from Mark, I don't think any further guessing
is particularly constructive.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next 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