diff --git a/retroarch.c b/retroarch.c index ddea95b050..45234ea146 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4986,12 +4986,16 @@ static void handle_translation_cb( start = i; else { + size_t found_string_len; found_string = (char*)malloc(i-start+1); strlcpy(found_string, body_copy+start+1, i-start); + + found_string_len = strlen(found_string); + if (curr_state == 1)/*image*/ { raw_image_file_data = (char*)unbase64(found_string, - strlen(found_string), + found_string_len, &new_image_size); curr_state = 0; } @@ -4999,7 +5003,7 @@ static void handle_translation_cb( else if (curr_state == 2) { raw_sound_data = (void*)unbase64(found_string, - strlen(found_string), &new_sound_size); + found_string_len, &new_sound_size); curr_state = 0; } #endif @@ -5194,6 +5198,7 @@ static void handle_translation_cb( error = "Can't allocate memory."; goto finish; } + rpng_set_buf_ptr(rpng, raw_image_file_data, new_image_size); rpng_start(rpng); while (rpng_iterate_image(rpng)); @@ -5211,13 +5216,13 @@ static void handle_translation_cb( int d,tw,th,tc; d=0; raw_image_data = (void*)malloc(image_width*image_height*3*sizeof(uint8_t)); - for (ui=0;uisystem_id + size_t label_len; + const char *system_id = core_info->system_id ? core_info->system_id : "core"; - + size_t system_id_len = strlen(system_id); const struct playlist_entry *entry = NULL; - playlist_t *current_playlist = playlist_get_cached(); + playlist_t *current_playlist = playlist_get_cached(); if (current_playlist) { @@ -5689,12 +5695,13 @@ static bool run_translation_service(bool paused) } if (!label) - label = path_basename(path_get(RARCH_PATH_BASENAME)); - system_label = (char*)malloc(strlen(label)+strlen(system_id)+3); - memcpy(system_label, system_id, strlen(system_id)); - memcpy(system_label+strlen(system_id), "__", 2); - memcpy(system_label+2+strlen(system_id), label, strlen(label)); - system_label[strlen(system_id)+2+strlen(label)] = '\0'; + label = path_basename(path_get(RARCH_PATH_BASENAME)); + label_len = strlen(label); + system_label = (char*)malloc(label_len + system_id_len + 3); + memcpy(system_label, system_id, system_id_len); + memcpy(system_label + system_id_len, "__", 2); + memcpy(system_label + 2 + system_id_len, label, label_len); + system_label[system_id_len + 2 + label_len] = '\0'; } if (!scaler) @@ -5813,20 +5820,22 @@ static bool run_translation_service(bool paused) if (system_label) { unsigned i; + size_t system_label_len = strlen(system_label); + /* include game label if provided */ - rf3 = (char *)malloc(15+strlen(system_label)); + rf3 = (char *)malloc(15 + system_label_len); memcpy(rf3, ", \"label\": \"", 12*sizeof(uint8_t)); - memcpy(rf3+12, system_label, strlen(system_label)); - memcpy(rf3+12+strlen(system_label), "\"}\0", 3*sizeof(uint8_t)); - for (i=12;i