I would suggest something like
if (dataSums == NULL) Rcpp::stop("Memory allocation failed!\n");
You have the corresponding (C++) layer of try / catch
wrapped around your code anyway
if you use Rcpp attributes, or inline, or when you do it by hand following the examples we have provided over the years. And given the C++ exception layer, you can just use it.
If your code layer needs extra cleanup, you may add that layer there. But C++ data structures will be unwound properly.