roboception / rc_genicam_api

Roboception convenience layer around GenICam and GigE Vision.
Other
111 stars 45 forks source link

Segfault in getBufferString #14

Closed wbt729 closed 5 years ago

wbt729 commented 5 years ago

I'm getting a segfault when calling Buffer::getTLType().

This happens in the getBufferString() function and can be fixed by the following code:

inline std::string getBufferString(const std::shared_ptr<const GenTLWrapper> &gentl,
                                   void *stream, void *buffer, GenTL::BUFFER_INFO_CMD cmd)
{
  std::string ret;

  GenTL::INFO_DATATYPE type;
  char tmp[1024]="";
  size_t size=sizeof(tmp);

  if (stream != 0 && buffer != 0)
  {
    //if (gentl->DSGetBufferInfo(stream, buffer, cmd, &type, &ret, &size) == GenTL::GC_ERR_SUCCESS)
    if (gentl->DSGetBufferInfo(stream, buffer, cmd, &type, &tmp, &size) == GenTL::GC_ERR_SUCCESS)
    {
      if (type == GenTL::INFO_DATATYPE_STRING)
      {
        ret=tmp;
      }
    }
  }

  return ret;
}
heikohimu commented 5 years ago

Thanks, I will add the fix.

flixr commented 5 years ago

Fixed with 38843f8fbf8eae676f4e94456a212c9c41a23745