Iterate over an array of pointers to structs

  c++, winapi

I have some legacy C code that calls a service using Windows Web Services. This will give me as a result a what looks like a pointer to a an array of pointers to structs. I’m trying to iterate over it to convert this to a more modern C++ vector of structs. However sometimes I get access violations or I’m reading just garbage values. I’m not sure if I;m doing it correctly or not.

The function has as an output parameter ReporteSupervisionBE***

When I call the function I do it like so:

ReporteSupervisionBE** rsup;
unsigned int rcount;
hr = BasicHttpBinding_IServicioEstadistico_ListarReportesSupervisionPorProyecto(proxy, idProject, &rcount, &rsup, heap, NULL, NULL, NULL, error);

(I’m passing rsup as a reference to this function)

Now, to get the structs I use the following for loop to insert these structs into a vector:

        if (result.count != 0) {
            std::vector<ReporteSupervisionBE> vec;
            for (size_t i = 1; i <= result.count; ++i) {
                ReporteSupervisionBE t = **result.rsup;

However in this loop I often see just garbage data(sometimes, not always) or even access violations. What could I be doing wrong?

Here are some examples of the data I get:

In this instance I dot garbage data:

enter image description here

But sometimes it works just fine:

enter image description here

The UI is wxWidgets in case it matters and this is how I get to the values in the vector I created above(just an example):

    svcListProjectsRESULT prjList = svc_listProjects();
    std::vector<std::string> prjVec = UTIL::project_vector(prjList);

    int index = 0;
    for (const auto& project : prjVec) {
        m_comboBox_proj->Insert(project, index);

Source: Windows Questions C++