Skip to content
  1. Oct 07, 2015
  2. May 30, 2015
  3. Feb 20, 2014
    • Neil Roberts's avatar
      Don't dereference an unitialised pointer in _cogl_container_of · fc4f882d
      Neil Roberts authored
      The previous implementation was dereferencing the sample pointer in
      order to get the offset to subtract from the member pointer. The
      resulting value is then only used to get a pointer to the member in
      order to calculate the offset so it doesn't actually read from the
      memory location and shouldn't cause any problems. However this is
      probably technically invalid and could have undefined behaviour. It
      looks like clang takes advantage of this undefined behaviour and
      doesn't actually offset the pointer. It also generates a warning when
      it does this.
      
      This patch splits the _cogl_container_of macro into two
      implementations. Previously the macro was always used in the list
      iterator macros like this:
      
      SomeType *sample = _cogl_container_of(list_node, sample, link)
      
      Instead of doing that there is now a new macro called
      _cogl_list_set_iterator which explicitly assigns to the sample pointer
      with an initial value before assigning to it again with the real
      offset. This redundant initialisation gets optimised out by compiler.
      
      The second macro is still called _cogl_container_of but instead of
      taking a sample pointer it just directly takes the type name. That way
      it can use the standard offsetof macro.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=723530
      
      
      
      Reviewed-by: default avatarRobert Bragg <robert@linux.intel.com>
      (cherry picked from commit 1efed1e0)
      fc4f882d
  4. Jan 24, 2014
  5. Jan 22, 2014
  6. Jan 20, 2014
  7. Dec 17, 2013
  8. Oct 28, 2013
  9. Oct 24, 2013
  10. Oct 15, 2013
  11. Sep 23, 2013