Permalink
Browse files

Fix missing null termination in tag list

  • Loading branch information...
WGautier committed Aug 16, 2018
1 parent bb916cf commit 9131a35375d3857f7d42bc06b26d8aad85ac9afc
Showing with 2 additions and 7 deletions.
  1. +2 −7 ext/sciruby/tensorflow_c/files/tf_tensor_helper.cc
@@ -259,17 +259,12 @@ TF_OperationDescription* input_list_helper(TF_OperationDescription* cdesc, TF_Ou
}

TF_Session* Saved_model_helper(TF_SessionOptions* cOpt, std::string cExportDir, std::vector<std::string> tags, TF_Graph* (graph_c),TF_Status* status_c){
char **tags_array;
tags_array = new char*[tags.size()];
const char* tags_array[tags.size()];
for(auto i = 0; i < tags.size(); i++) {
tags_array[i] = new char[tags[i].length()];
for(auto j = 0; j < tags[i].length(); j++) tags_array[i][j] = tags[i][j];
tags_array[i] = tags[i].c_str();
}
const char* ExportDir = cExportDir.c_str();
auto cSess = TF_LoadSessionFromSavedModel(cOpt, NULL, ExportDir,&tags_array[0], tags.size(), graph_c, NULL, status_c);
for(auto i = 0; i < tags.size(); i++) {
free(tags_array[i]);
}
TF_DeleteSessionOptions(cOpt);
return cSess;
}

0 comments on commit 9131a35

Please sign in to comment.