Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-173

passing a NULL to memcpy in the new O_DIRECT code

    • Type: Icon: Task Task
    • Resolution: Done
    • WT1.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Michael, lint says:

      <                                                 _
      <               memcpy(newp, p, bytes_allocated);
      < os_posix/os_alloc.c  137  Warning 668: Possibly passing a null pointer to
      <     function 'memcpy(void *, const void *, unsigned long)', arg. no. 2
      <     [Reference: file os_posix/os_alloc.c: line 129]
      < os_posix/os_alloc.c  129  Info 831: Reference cited in prior message
      

      Here's the code:

      
                      if (p == NULL && session != NULL && S2C(session)->stats != NULL)
                              WT_CSTAT_INCR(session, memalloc);
      
                      if ((ret = posix_memalign(&newp,
                          S2C(session)->buffer_alignment,
                          bytes_to_allocate)) != 0)
                              WT_RET_MSG(session, ret, "memory allocation");
      
                      memcpy(newp, p, bytes_allocated);
      

      It looks to me like we might pass a NULL value for p into memcpy?

            Assignee:
            michael.cahill@mongodb.com Michael Cahill (Inactive)
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: