Return-Path: Delivered-To: apmail-httpd-apreq-dev-archive@www.apache.org Received: (qmail 27501 invoked from network); 18 Sep 2003 01:08:55 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 18 Sep 2003 01:08:55 -0000 Received: (qmail 61164 invoked by uid 500); 18 Sep 2003 01:08:38 -0000 Delivered-To: apmail-httpd-apreq-dev-archive@httpd.apache.org Received: (qmail 61132 invoked by uid 500); 18 Sep 2003 01:08:38 -0000 Mailing-List: contact apreq-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list apreq-dev@httpd.apache.org Received: (qmail 61119 invoked from network); 18 Sep 2003 01:08:37 -0000 Received: from unknown (HELO beauty.rexursive.com) (202.59.98.58) by daedalus.apache.org with SMTP; 18 Sep 2003 01:08:37 -0000 Received: by beauty.rexursive.com (Postfix, from userid 52) id AE7601E8D7; Thu, 18 Sep 2003 11:05:14 +1000 (EST) Received: from 203.53.38.230 ([203.53.38.230]) by imp.rexursive.com (IMP) with HTTP for ; Thu, 18 Sep 2003 11:05:14 +1000 Message-ID: <1063847114.3f6904ca68303@imp.rexursive.com> Date: Thu, 18 Sep 2003 11:05:14 +1000 From: Bojan Smojver To: apreq-dev@httpd.apache.org Subject: Bug in apreq_attr_to_type macro MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N The following macro produces unwanted results if P == NULL. #define apreq_attr_to_type(T,A,P) ( (T*) ((char*)(P)-offsetof(T,A)) ) Basically, you get back a non-NULL value, thus believing that this is an actual valid memory address. Two problems with that: you can't tell that you actually found nothing and the code segfaults. Something like this would be a bit better IMHO: #define apreq_attr_to_type(T,A,P) \ ( (P) ? ((T*) ((char*)(P)-offsetof(T,A))) : NULL ) I've tested this in my code and it seems to work, at least for apreq_cookie() call, which relies on the above macro (through apreq_value_to_cookie macro) to fetch cookies from the table. I've tested this with Apache 2.0.47 on Red Hat 9. -- Bojan