[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] [PATCH] MHD_add_response_header: Check on passed nul
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] [PATCH] MHD_add_response_header: Check on passed nullptr |
Date: |
Fri, 28 Jan 2022 11:15:20 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 |
On 1/28/22 11:08 AM, Alexander Dahl wrote:
> I think this tends to be a question of design philosophy. Some developers
> expect libraries to never segfault.
That is something you cannot guarantee in C, basically ever. Libraries
always require that they are called with correct arguments. Sure, a
NULL pointer could be detected, but calling a function with a NULL
pointer that is not documented to accept one is a bug in the calling
application and results in undefined (!) behavior. That is normal in C
and in MHD's case the "desired" outcome. Just check for the NULL
response object before calling the MHD function, it's better for
everyone involved ;-).