From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!4g2000yqo.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Fri, 4 Feb 2011 01:21:20 -0800 (PST) Organization: http://groups.google.com Message-ID: <3abe5305-bf28-4bec-9f55-b382d7140c17@4g2000yqo.googlegroups.com> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1296811280 29046 127.0.0.1 (4 Feb 2011 09:21:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Feb 2011 09:21:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 4g2000yqo.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:16861 Date: 2011-02-04T01:21:20-08:00 List-Id: Jeffrey Carter wrote: >> *Every* time I look at C code, I see a bug. >> I think this is a bug; it should read "message++" since you want to >> increment the pointer, not the pointed-to character. > > As others have explained, this is not an error, though the unused dereference is > wasted effort. However, if message does not contain zero, this will happily read > memory outside of message, and if the first zero encountered follows enough > bytes, it will happily write memory outside of vidmem. OK, so my hunch was wrong; there was not one but two bugs in that line. Funny to see that my quickly-written, untested Ada code cannot possibly have these bugs. Proper arrays prevent reading the terminating null character since there isn't one; the modular types for the indexes prevent writing outside the video buffer. Once more, praise the Lady :) -- Ludovic Brenta.