delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/04/13:43:13

Date: Sun, 4 Oct 1998 13:42:54 -0400 (EDT)
Message-Id: <199810041742.NAA01799@indy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <XlOR1.447$l93.2198969@proxye1.nycap.rr.com> (spam@somebody.else)
Subject: Re: SIGSEGV under DOS, but not Win9x?

> int VGANewBitmap(BITMAP *bmp,int W,int H)
> {
>    bmp->Data = (byte *)malloc(W*H);

> I get an immediate segfault if I use the declarations:
>    BITMAP *bitmap;
>    VGANewBitmap(bitmap,256,240);

You are declaring a pointer (bitmap) and passing it to a function
(which dereferences it) but you never initialize the pointer to point
to anything.  If the undefined initial value happens to be zero, your
program will crash.

> This happens only under DOS+cwsdpmi, but not under Win9x.

cwsdpmi is a lot stricter than Windows; if you have a problem in
cwsdpmi and not windows, it's probably a bug in your code.

- Raw text -


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