-
-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape file name commas in startup command #67
Conversation
softmmu/vl.c
Outdated
@@ -2921,7 +2945,7 @@ void qemu_init(int argc, char **argv, char **envp) | |||
xemu_settings_get_bool(XEMU_SETTINGS_SYSTEM_SHORTANIM, &short_animation); | |||
|
|||
fake_argv[fake_argc++] = g_strdup_printf("xbox%s%s%s", | |||
strlen(bootrom_path) > 0 ? g_strdup_printf(",bootrom=%s", bootrom_path) : "", // Leak | |||
strlen(bootrom_path) > 0 ? g_strdup_printf(",bootrom=%s", strdup_double_commas(bootrom_path)) : "", // Leak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's free
the escaped paths after using g_strdup_printf
softmmu/vl.c
Outdated
// Duplicate commas to escape them | ||
static char *strdup_double_commas(const char *input) { | ||
size_t length = 0; | ||
for(const char *i = input; *i; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits: Please have a space after for
and while
, if
below as well
softmmu/vl.c
Outdated
char *output = malloc(length + 1); | ||
char *out = output; | ||
const char *in = input; | ||
while(*in) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest a slightly more succinct version:
const char *in = input;
char *out = output;
while (*in) {
if (*in == ',') {
*(out++) = ',';
}
*(out++) = *(in++);
}
Looks good, just some minor changes requested. Thanks for looking into it! |
Thanks! |
This fixes #65