[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-cgicc] Re: help-cgicc Digest, Vol 34, Issue 2

From: Steven King
Subject: [help-cgicc] Re: help-cgicc Digest, Vol 34, Issue 2
Date: Mon, 31 Jul 2006 07:33:01 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060503 Debian/1.7.8-1sarge6

Hi Juju,

This program was causing a segmentation fault at the isEmpty() line when I ran it from the command line.

It is caused by trying to call isEmpty() on an empty object. If the call "fvalue1 != (*formData).end()" fails, this means that the iterator is pointing to nothing so you cant call methods on it.

To fix the tutorial, simply change the order on the if and let precedence take care of checking for an empty iterator, that is:

if( !fvalue1->isEmpty() && fvalue1 != (*formData).end())


if((fvalue1 != (*formData).end()) && !fvalue1->isEmpty())

Also, the output HTML is incorrect -> you need to remove the second html() call.


Steve King

address@hidden wrote:

Send help-cgicc mailing list submissions to

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to

You can reach the person managing the list at

When replying, please edit your Subject line so it is more specific
than "Re: Contents of help-cgicc digest..."

Today's Topics:

  1. problems with forms submitted via http POST


Message: 1
Date: Sat, 29 Jul 2006 15:54:22 +0200
From: address@hidden
Subject: [help-cgicc] problems with forms submitted via http POST
To: address@hidden
Message-ID: <address@hidden>
Content-Type: text/plain; charset=ISO-8859-1


my cgi program and a tutorial cgicc program both crash when
called with the http "POST" method and with some ?key=value
added to the url.

The program crash is in the call to isEmpty() in a context like here:
form_iterator fvalue1 = formData.getElement("value1");
if( !fvalue1->isEmpty() && fvalue1 != (*formData).end())
cout << "Value1: " << **fvalue1 << endl;

this problem only shows when all of the 3 following conditions concur:
a) the cgi program receives data via the POST method
b) the url has key/value pairs added as in the GET method
c) there's a call to FormEntry::isEmpty() or FormEntry::length

- if instead of a) i use http GET, then it works fine, and i can even
use code
like the above to retrieve the http get vars.
- if instead of b) there are no GET-type vars at the end of the url, a
POST request
is processed just fine. However, it seems that any cgi program used with
http post
shows this problem if the user just adds ?somekey=somevalue to the url.
- if instead of c) i don't use FormEntry, it works fine even if i use
post with ?key=value
added to the url. i could even parse these manually from the query
string (where they
do get transferred).

if you want to reproduce this problem, just compile the example code from
and call it with "POST" method AND adding any ?key=value to the url.

is this a bug or  did i overlook something?



help-cgicc mailing list

End of help-cgicc Digest, Vol 34, Issue 2


<> Eminence Technology Pty Ltd
PO Box 118, Moorooka QLD 4105
Web: <>
Ph: +61-7-3277-4100
Fax: +61-7-3105-7484

reply via email to

[Prev in Thread] Current Thread [Next in Thread]