www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/26/20:47:02

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: sscanf() and NULL pointers
Date: Thu, 26 Dec 1996 16:33:28 -0800
Organization: Alcyone Systems
Lines: 24
Message-ID: <32C31958.56C1738E@alcyone.com>
References: <Pine DOT GSO DOT 3 DOT 95 DOT 961226182357 DOT 3119A-100000 AT hops DOT cs DOT jhu DOT edu>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Michael Phelps wrote:

>         Is there a defined behavior for sscanf() when passed a NULL
> pointer?  One of my programs worked fine under Win 95 but crashed with
> CWSDPMI r3, presumably because CWSDPMI detects NULL pointer dereferences.
> I had assumed that sscanf() would return a value of zero when passed a
> NULL pointer.

Unless specifically indicated, passing a null pointer to any function
expecting a pointer is a bad thing.  There are specific cases where null
pointers are allowed, but unless documented, you're doing a bad thing and
you should expect implementation-dependent behavior, though almost always
bad.

Some DPMI hosts crash when dereferencing null pointers; others don't.  This
is true of operating systems and architectures in general.  It is, however,
always a bad thing.

-- 
                             Erik Max Francis | max AT alcyone DOT com
                              Alcyone Systems | http://www.alcyone.com/max/
                         San Jose, California | 37 20 07 N 121 53 38 W
                                 &tSftDotIotE | R^4: the 4th R is respect
     "You must surely know if man made heaven | Then man made hell"

- Raw text -


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