Opened on 08/28/2014 at 04:58:21 PM

Closed on 12/15/2014 at 08:19:26 AM

Last modified on 12/15/2014 at 09:33:18 AM

#1283 closed change (fixed)

In PluginClass.cpp wrong usage of memset

Reported by: sergz Assignee: sergz
Priority: P4 Milestone: Adblock-Plus-for-Internet-Explorer-1.3
Module: Adblock-Plus-for-Internet-Explorer Keywords: goodfirstbug
Cc: Blocked By:
Blocking: Platform: Internet Explorer
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):



The code is

wchar_t szClassName[MAX_PATH];
memset(szClassName, 0, MAX_PATH);

Apparently it nullifies only the first half of characters. it should be memset(szClassName, 0, MAX_PATH * sizeof(wchar_t));

What to change

  • replace all memset calls by std::array::fill to clear the arrays and change the variable type
  • check all usages of sizeof. Replace sizeof(TYPE_NAME) by sizeof(variable) except for the allocation case. It's safer to use the latter variant.
  • replace zero initialization via ZeroMemory and memset by SomeType var = {}. It is list initialization which falls back on value initialization which initializes the everything to zero if there is no default constructor. We cannot use value initialization right now because it's not supported by c++ compiler from MSVS2012.

Attachments (0)

Change History (5)

comment:1 Changed on 09/01/2014 at 03:18:55 PM by sergz

  • Review URL(s) modified (diff)

comment:2 Changed on 09/09/2014 at 07:32:51 AM by oleksandr

  • Cc added
  • Keywords goodfirstbug added
  • Priority changed from Unknown to P4
  • Ready set

comment:3 Changed on 09/15/2014 at 10:48:27 AM by sergz

  • Status changed from new to reviewing

comment:4 Changed on 12/15/2014 at 08:19:26 AM by oleksandr

  • Resolution set to fixed
  • Review URL(s) modified (diff)
  • Status changed from reviewing to closed

comment:5 Changed on 12/15/2014 at 09:33:18 AM by fhd

  • Milestone set to Adblock-Plus-for-Internet-Explorer-1.3

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from sergz.
Note: See TracTickets for help on using tickets.