Skip to content

Commit

Permalink
Fix unsafe vector data pointer access
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Apr 7, 2024
1 parent b25ab9d commit dc46f97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ inline std::string raster_to_string(std::vector<unsigned int> raster_, int w, in
}

std::vector<std::uint8_t> buffer;
png_set_rows(png, info, &rows[0]);
png_set_rows(png, info, rows.data());
png_set_write_fn(png, &buffer, png_memory_write, NULL);
png_write_png(png, info, PNG_TRANSFORM_IDENTITY, NULL);
png_destroy_write_struct(&png, &info);
Expand Down
4 changes: 2 additions & 2 deletions src/unigd_external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using unigd_handle_t = unigd_handle<unigd::unigd_device>;

unigd_find_results find_results::c_repr()
{
return {state, static_cast<plot_index_t>(ids.size()), &ids[0]};
return {state, static_cast<plot_index_t>(ids.size()), ids.data()};
}

int api_test_fun() { return 7; }
Expand Down Expand Up @@ -163,7 +163,7 @@ UNIGD_RENDERERS_HANDLE api_renderers(unigd_renderers_list *renderer)
re->emplace_back(it.second.info);
}

*renderer = {&((*re)[0]), re->size()};
*renderer = {(*re).data(), re->size()};

return re;
}
Expand Down

0 comments on commit dc46f97

Please sign in to comment.