From: Alexandre Julliard Subject: Re: [PATCH] include: Add and use a global heap_strdupW() helper Message-Id: <87a7wdb4lk.fsf@winehq.org> Date: Tue, 13 Feb 2018 10:50:47 +0100 In-Reply-To: (Michael Stefaniuc's message of "Tue, 13 Feb 2018 10:22:13 +0100") References: <20180209204421.12241-1-mstefani@winehq.org> <87o9kuo6ac.fsf@winehq.org> <87vaf1riir.fsf@winehq.org> Michael Stefaniuc writes: >> The current usage is clean only because we are not checking for >> allocation failure, but that's broken. If we add proper handling, then >> the NULL checks will be needed anyway. > I assumed you want less HeapAlloc failure handling and not more! > Especially as in the strdup cases the current "return NULL" seems to > be good enough in practice. > I don't remember to have ever seen a patch that adds extra error > handling for that case. You could argue that strdup() should be treated as a nofail function, but then you should remove the second null check and let it crash on the memcpy, or use HEAP_GENERATE_EXCEPTIONS. I'd prefer to have an explicit xstrdup() function for this though, and have the regular strdup() require error handling. -- Alexandre Julliard julliard@winehq.org