warvair / peerblock

Automatically exported from code.google.com/p/peerblock
Other
0 stars 1 forks source link

PVS-Studio #426

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I check peerblock, by using the PVS-Studio http://www.viva64.com/en/pvs-studio/ 
. Nothing interesting. I noticed only few of strange fragments. I decided to 
write about it.

V563 It is possible that this 'else' branch must apply to the previous 'if' 
statement. peerblock editlistproc.cpp 91

static void EditList_OnCommand(....)
{
  ...
  if(l=dynamic_cast<StaticList*>(*list))
    if(l->File!=file) {
      l->File=file;
      g_ret|=LISTS_NEEDRELOAD;
    }
  else {
    delete *list;
    *list=l=new StaticList;
    l->File=file;
    g_ret|=LISTS_NEEDRELOAD;
  }
  ...
}

----------------------------

V576 Incorrect format. Consider checking the fourth actual argument of the 
'swprintf_s' function. The pointer to string of wchar_t type symbols is 
expected. peerblock pb.cpp 153

#define PB_BLDSTR "PeerBlock " STRINGIFY(PB_VER_MAJOR) "." \
        STRINGIFY(PB_VER_MINOR) "+" " (r" \
        STRINGIFY(PB_VER_BUILDNUM) ") - DEV BUILD"

int WINAPI _tWinMain(....)
{
  ...
  TCHAR buf[64];
  swprintf_s(buf, sizeof(buf)/2, L"%S", PB_BLDSTR);
  ...
}

And here:
V576 Incorrect format. Consider checking the fourth actual argument of the 
'swprintf_s' function. The pointer to string of wchar_t type symbols is 
expected. peerblock pb.cpp 232
V576 Incorrect format. Consider checking the fourth actual argument of the 
'swprintf_s' function. The pointer to string of wchar_t type symbols is 
expected. peerblock updatelists.cpp 314
V576 Incorrect format. Consider checking the fourth actual argument of the 
'swprintf_s' function. The pointer to string of wchar_t type symbols is 
expected. peerblock updatelists.cpp 318

----------------------------

V579 The Curl_strntoupper function receives the pointer and its size as 
arguments. It is possibly a mistake. Inspect the third argument. libcurl rtsp.c 
753

void Curl_strntoupper(char *dest, const char *src, size_t n)
{
  if(n < 1)
    return;

  do {
    *dest++ = Curl_raw_toupper(*src);
  } while(*src++ && --n);
}

CURLcode Curl_rtsp_parseheader(....)
{
  ...
  char *temp = strdup(header);
  ...
  Curl_strntoupper(temp, temp, sizeof(temp));
  ...
}

Original issue reported on code.google.com by karpov2...@gmail.com on 25 Apr 2012 at 10:21