Skip to content

Commit

Permalink
Fix missing null termination in tag list
Browse files Browse the repository at this point in the history
  • Loading branch information
WGautier committed Aug 16, 2018
1 parent bb916cf commit 9131a35
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ext/sciruby/tensorflow_c/files/tf_tensor_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9131a35

Please sign in to comment.