Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Develop fix save conversion #780

Merged
merged 5 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gldcore/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,10 @@ int pcloses(FILE *iop, bool wait=true)

int GldMain::subcommand(const char *format, ...)
{
char *command;
char *command = NULL;
va_list ptr;
va_start(ptr,format);
if ( vasprintf(&command,format,ptr) < 0 )
if ( vasprintf(&command,format,ptr) < 0 || command == NULL )
{
output_error("GldMain::subcommand(format='%s',...): memory allocation failed",format);
return -1;
Expand Down Expand Up @@ -658,6 +658,7 @@ int GldMain::subcommand(const char *format, ...)
}
output_verbose("subcommand '%s' -> status = %d",command,rc);
}
free(command);
return rc;
}

Expand Down
10 changes: 4 additions & 6 deletions gldcore/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ int saveall(const char *filename)
}
if ( ! known_format )
{
char converter_command[1024];
int rc;
char converter_name[1024];
char input_name[1024];
Expand All @@ -72,13 +71,12 @@ int saveall(const char *filename)
return 0;
}
sprintf(converter_name,"glm2%s.py",ext);
const char *converter_path = find_file(converter_name,NULL,R_OK);
if ( ! converter_path )
char converter_path[1024];
if ( ! find_file(converter_name,NULL,R_OK,converter_path,sizeof(converter_path)) )
{
/* try using python output converter through json */
sprintf(converter_name,"json2%s.py",ext);
const char *converter_path = find_file(converter_name,NULL,R_OK);
if ( ! converter_path )
if ( ! find_file(converter_name,NULL,R_OK,converter_path,sizeof(converter_path)) )
{
output_error("saveall: extension '.%s' not a known format", ext);
/* TROUBLESHOOT
Expand Down Expand Up @@ -131,7 +129,7 @@ int saveall(const char *filename)
save_options++;
buffer[strlen(buffer)-1] = '\0';
}
rc = my_instance->subcommand(converter_command,"/usr/local/bin/python3 %s -i %s -o %s %s",converter_path,input_name,filename,save_options?save_options:"");
rc = my_instance->subcommand("/usr/local/bin/python3 %s -i %s -o %s %s",converter_path,input_name,filename,save_options?save_options:"");
if ( rc != 0 )
{
output_error("conversion from '%s' to output file '%s' failed (code %d)", input_name, filename, rc);
Expand Down