Skip to content

Commit

Permalink
Fixed a possible crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Jan 13, 2019
1 parent 89bb90f commit 707657f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/core/fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,14 @@ void fds_diff_op(BYTE mode, uint32_t position, WORD value) {
uTCHAR ext[10], basename[255], *last_dot;

gui_utf_basename(info.rom.file, basename, usizeof(basename));
usnprintf(file, usizeof(file), uL("" uPERCENTs DIFF_FOLDER "/" uPERCENTs),
info.base_folder, basename);
usnprintf(file, usizeof(file), uL("" uPERCENTs DIFF_FOLDER "/" uPERCENTs), info.base_folder, basename);
usnprintf(ext, usizeof(ext), uL("dif"));

// rintraccio l'ultimo '.' nel nome
last_dot = ustrrchr(file, uL('.'));
// elimino l'estensione
*last_dot = 0x00;
if ((last_dot = ustrrchr(file, uL('.')))) {
// elimino l'estensione
*last_dot = 0x00;
};
// aggiungo l'estensione
ustrcat(file, ext);

Expand Down
14 changes: 8 additions & 6 deletions src/core/mappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,10 @@ void map_prg_ram_init(void) {
uL("" uPERCENTs PRB_FOLDER "/" uPERCENTs), info.base_folder, basename);

/* rintraccio l'ultimo '.' nel nome */
last_dot = ustrrchr(prg_ram_file, uL('.'));
/* elimino l'estensione */
*last_dot = 0x00;
if ((last_dot = ustrrchr(prg_ram_file, uL('.')))) {
/* elimino l'estensione */
*last_dot = 0x00;
}
/* aggiungo l'estensione prb */
ustrcat(prg_ram_file, uL(".prb"));
/* provo ad aprire il file */
Expand Down Expand Up @@ -1175,9 +1176,10 @@ void map_prg_ram_battery_save(void) {
uL("" uPERCENTs PRB_FOLDER "/" uPERCENTs), info.base_folder, basename);

/* rintraccio l'ultimo '.' nel nome */
last_dot = ustrrchr(prg_ram_file, uL('.'));
/* elimino l'estensione */
*last_dot = 0x00;
if ((last_dot = ustrrchr(prg_ram_file, uL('.')))) {
/* elimino l'estensione */
*last_dot = 0x00;
}
/* aggiungo l'estensione prb */
ustrcat(prg_ram_file, uL(".prb"));
/* apro il file */
Expand Down
7 changes: 4 additions & 3 deletions src/core/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ BYTE patcher_ctrl_if_exist(uTCHAR *patch) {
uTCHAR *last_dot;

// rintraccio l'ultimo '.' nel nome
last_dot = ustrrchr(file, uL('.'));
// elimino l'estensione
*last_dot = 0x00;
if ((last_dot = ustrrchr(file, uL('.')))) {
// elimino l'estensione
*last_dot = 0x00;
};
// aggiungo l'estensione
ustrcat(file, patch_ext[i]);

Expand Down
7 changes: 4 additions & 3 deletions src/core/save_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,10 @@ static uTCHAR *name_slot_file(BYTE slot) {
}

// rintraccio l'ultimo '.' nel nome
last_dot = ustrrchr(file, uL('.'));
// elimino l'estensione
*last_dot = 0x00;
if ((last_dot = ustrrchr(file, uL('.')))) {
// elimino l'estensione
*last_dot = 0x00;
}
// aggiungo l'estensione
ustrcat(file, ext);

Expand Down

0 comments on commit 707657f

Please sign in to comment.