libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 45c6900e368f4269b2eb435eab32d9f5e98da072
parent 57f2c46ede626e2e4334f3063195b425e74548f2
Author: Sebastian Gerhardt <sebgerhardt@gmx.net>
Date:   Tue, 19 Aug 2008 13:03:27 +0000

corrected error handling in post processing example


Diffstat:
Mdoc/examples/simplepost.c | 7+++++--
Mdoc/processingpost.inc | 6++++--
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c @@ -86,7 +86,8 @@ void request_completed (void *cls, struct MHD_Connection *connection, void **con if (con_info->answerstring) free (con_info->answerstring); } - free (con_info); + free (con_info); + *con_cls = NULL; } @@ -100,6 +101,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const ch con_info = malloc (sizeof (struct connection_info_struct)); if (NULL == con_info) return MHD_NO; + con_info->answerstring = NULL; if (0 == strcmp (method, "POST")) { @@ -137,7 +139,8 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const ch return MHD_YES; } - else return send_page (connection, con_info->answerstring); + else + if (NULL != con_info->answerstring) return send_page (connection, con_info->answerstring); } return send_page(connection, errorpage); diff --git a/doc/processingpost.inc b/doc/processingpost.inc @@ -122,7 +122,8 @@ void request_completed (void *cls, struct MHD_Connection *connection, void **con if (con_info->answerstring) free (con_info->answerstring); } - free (con_info); + free (con_info); + *con_cls = NULL; } @end verbatim @noindent @@ -157,6 +158,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection, const ch con_info = malloc (sizeof (struct connection_info_struct)); if (NULL == con_info) return MHD_NO; + con_info->answerstring = NULL; @end verbatim @noindent @@ -214,7 +216,7 @@ considered---all of it. return MHD_YES; } - else return send_page (connection, con_info->answerstring); + else if (NULL != con_info->answerstring) return send_page (connection, con_info->answerstring); } @end verbatim @noindent