delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/07/29/17:00:16

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Received: by 10.224.163.14 with SMTP id y14mr67097260qax.3.1375130704150;
Mon, 29 Jul 2013 13:45:04 -0700 (PDT)
X-Received: by 10.49.35.225 with SMTP id l1mr1307232qej.1.1375130704131; Mon,
29 Jul 2013 13:45:04 -0700 (PDT)
Newsgroups: comp.os.msdos.djgpp
Date: Mon, 29 Jul 2013 13:45:03 -0700 (PDT)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2.173.191.8; posting-account=v5xbdQoAAAAOGc9Ccc-kLZyobvPlN3Qr
NNTP-Posting-Host: 2.173.191.8
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <21e77579-1a40-4442-8111-fc976fba78fc@googlegroups.com>
Subject: _CRT0_FLAG_NULLOK
From: Georg Potthast <dosusb AT googlemail DOT com>
Injection-Date: Mon, 29 Jul 2013 20:45:04 +0000
Bytes: 1791
Lines: 14
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I got my program to work fine in real mode DOS now when I set this flag:

int _crt0_startup_flags = _CRT0_FLAG_NULLOK | _CRT0_FLAG_FILL_SBRK_MEMORY;

Without this line above it crashes when executing "atoi" in these lines:

const char* testchar = NULL;
int testint = atoi(testchar);
printf("testint:%d\n",testint);

I thought if I initialize a pointer to NULL I avoid problems like that. In my program I call a library function which returns NULL if it cannot read the requested value. I shortend this to testchar = NULL in the snippet above.

When I set the _crt0_startup_flags like above the variable testint gets the value zero. But is there a danger that the pointer could override memory, e.g. part of the operating system? Or why should I avoid _CRT0_FLAG_NULLOK ?

Georg

- Raw text -


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