Loading ...
Sorry, an error occurred while loading the content.
 

uninitialized variable reference in Poller_poll.cc

Expand Messages
  • dankegel
    I and Vasan Sundar recently ported Poller_poll.cc to c, and I m using it in a fun little load test app at work. While debugging that app, I happened to run
    Message 1 of 1 , Oct 3 11:33 AM
      I and Vasan Sundar recently ported Poller_poll.cc to c,
      and I'm using it in a fun little load test app at work.
      While debugging that app, I happened to run valgrind on it,
      and valgrind found an uninitialized memory bug in Poller_poll.c.
      Here's the fix; the corresponding fix to the C++ version is identical.

      (I'm starting to really like Valgrind... it's in debian testing,
      so all I had to do to get it was 'apt-get install valgrind',
      but it's a real easy compile and install from source, too.
      It's at http://developer.kde.org/~sewardj/ )

      --- ../se4/Poller_poll.c Fri Sep 27 15:36:17 2002
      +++ Poller_poll.c Thu Oct 3 11:54:17 2002
      @@ -29,6 +29,7 @@

      int Poller_poll_init(Poller_poll *pp)
      {
      + int i;
      DPRINT(("init()\n"));

      // Allocate things indexed by file descriptor.
      @@ -37,6 +38,9 @@
      pp->m_fd2pfdnum = (int *)malloc(sizeof(int) *
      pp->m_fd2client_alloc);
      if (!pp->m_fd2pfdnum)
      return ENOMEM;
      + // Clear new elements
      + for (i=0; i<pp->m_fd2client_alloc; i++)
      + pp->m_fd2pfdnum[i] = -1;

      // Allocate things indexed by client number.
      pp->m_pfds_used = 0;
    Your message has been successfully submitted and would be delivered to recipients shortly.