mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-02 19:55:14 +00:00
Fix null deref assert on release builds related to fortunes
This commit is contained in:
parent
b25d91a0e7
commit
f95e3f5514
@ -545,9 +545,9 @@ R_API bool r_line_hist_save(const char *file) {
|
||||
r_return_val_if_fail (file && *file, false);
|
||||
int i;
|
||||
bool ret = false;
|
||||
char *p, *path = r_str_home (file);
|
||||
char *path = r_str_home (file);
|
||||
if (path) {
|
||||
p = (char *) r_str_lastbut (path, R_SYS_DIR[0], NULL); // TODO: use fs
|
||||
char *p = (char *) r_str_lastbut (path, R_SYS_DIR[0], NULL); // TODO: use fs
|
||||
if (p) {
|
||||
*p = 0;
|
||||
if (!r_sys_mkdirp (path)) {
|
||||
@ -565,11 +565,9 @@ R_API bool r_line_hist_save(const char *file) {
|
||||
fputs (I.history.data[i], fd);
|
||||
fputs ("\n", fd);
|
||||
}
|
||||
fclose (fd);
|
||||
ret = true;
|
||||
} else {
|
||||
fclose (fd);
|
||||
}
|
||||
fclose (fd);
|
||||
}
|
||||
}
|
||||
end:
|
||||
|
@ -3699,7 +3699,12 @@ R_API int r_core_config_init(RCore *core) {
|
||||
free (whoami);
|
||||
SETCB ("cfg.fortunes", "true", &cb_cfg_fortunes, "if enabled show tips at start");
|
||||
RList *fortune_types = r_core_fortune_types ();
|
||||
char *fts = r_str_list_join(fortune_types, ",");
|
||||
if (!fortune_types) {
|
||||
fortune_types = r_list_newf (free);
|
||||
r_list_append (fortune_types, "tips");
|
||||
r_list_append (fortune_types, "fun");
|
||||
}
|
||||
char *fts = r_str_list_join (fortune_types, ",");
|
||||
r_list_free (fortune_types);
|
||||
char *fortune_desc = r_str_newf ("type of fortunes to show(%s)", fts);
|
||||
SETCB ("cfg.fortunes.type", fts, &cb_cfg_fortunes_type, fortune_desc);
|
||||
|
@ -3769,6 +3769,7 @@ R_API void r_str_stripLine(char *str, const char *key) {
|
||||
}
|
||||
|
||||
R_API char *r_str_list_join(RList *str, const char *sep) {
|
||||
r_return_val_if_fail (str && sep, NULL);
|
||||
RStrBuf *sb = r_strbuf_new ("");
|
||||
const char *p;
|
||||
while ((p = r_list_pop_head (str))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user