LCDproc development and user support list

Text archives Help


[Lcdproc] [PATCH] Missing NULL malloc() check in server/menuitem.c


Chronological Thread 
  • From: bsdfan at nurfuerspam.de (Markus Dolze)
  • Subject: [Lcdproc] [PATCH] Missing NULL malloc() check in server/menuitem.c
  • Date: Sat, 30 May 2009 12:39:31 +0200

Andre Guibert de Bruet wrote:
>
> I have addressed a bunch of malloc-related issues this source file in
> the attached patch (Against HEAD). I have a list of additional issues
> with menuitem.c which I will address at a later date.
>
> Could the attached patch be committed upon review?
>

Hi,


I had a look at your patch and the menu* part. It is perhaps one of the
most complex part of LCDproc.

Tracing from menuitem_create to all more specific menuitem_create_*()
functions and the calling functions I was puzzled by the result handling
and rewrote parts of it. Patch is attached.

Some remarks:

1. All calls to malloc are checked for NULL now (based on Andre's

patch).
2. All calls to strdup are checked as well, because subsequent calls to
strlen(NULL) will result in core dump.
3. It is not necessary to free allocated memory and duplicates string in
menuitem_create_*() IF menuitem_destroy() is called (the latter frees
all allocated strings). However, I am not sure if I need to
initialize all pointer to NULL before.
4. All calls to menu_create() are checked for NULL, exiting the current
function in most cases.
5. I moved the creation of the test menu into its own function (as a
result of 3).

Regards
Markus
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: menu-alloc.patch
URL:
<http://lists.omnipotent.net/pipermail/lcdproc/attachments/20090530/3280bac2/attachment.txt>




Archive powered by MHonArc 2.6.18.

Top of page