X-Git-Url: http://git.videolan.org/?p=vlc.git;a=blobdiff_plain;f=modules%2Fkeystore%2Fplaintext.c;h=b8ea30e4aef67420a3fb87c52f9a7b012968ae58;hp=cf9f338ad59c00f60132cad7285440d63cb14f46;hb=38452bb3da7b53b9894ad999fc733224ecc2b5f2;hpb=cb4130bf9a7aa549ef09650c0141f2539e795001 diff --git a/modules/keystore/plaintext.c b/modules/keystore/plaintext.c index cf9f338ad5..b8ea30e4ae 100644 --- a/modules/keystore/plaintext.c +++ b/modules/keystore/plaintext.c @@ -360,15 +360,7 @@ Store(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX], vlc_keystore_entry *p_entry = list_get_entry(p_list, ppsz_values, NULL); if (p_entry) - { - free(p_entry->p_secret); - p_entry->p_secret = NULL; - for (unsigned int i = 0; i < KEY_MAX; ++i) - { - free(p_entry->ppsz_values[i]); - p_entry->ppsz_values[i] = NULL; - } - } + vlc_keystore_release_entry(p_entry); else { p_entry = list_new_entry(p_list); @@ -441,8 +433,7 @@ Remove(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX]) while ((p_entry = list_get_entry(p_list, ppsz_values, &i_index))) { - free(p_entry->p_secret); - p_entry->p_secret = NULL; + vlc_keystore_release_entry(p_entry); i_count++; } @@ -463,12 +454,13 @@ CleanUp(vlc_keystore_sys *p_sys) { if (p_sys->b_error) { - if (truncate0(p_sys->i_fd)) + if (p_sys->i_fd != -1 && truncate0(p_sys->i_fd)) vlc_unlink(p_sys->psz_file); } #ifdef HAVE_FLOCK - flock(p_sys->i_fd, LOCK_UN); + if (p_sys->i_fd != -1) + flock(p_sys->i_fd, LOCK_UN); #endif fclose(p_sys->p_file); } @@ -502,14 +494,16 @@ Open(vlc_object_t *p_this) p_sys->psz_file = psz_file; p_sys->p_file = vlc_fopen(p_sys->psz_file, "a+"); + p_sys->i_fd = -1; if (!p_sys->p_file) { CleanUp(p_sys); return VLC_EGENERIC; } - p_sys->i_fd = fileno(p_sys->p_file); - if (p_sys->i_fd == -1) + + int i_fd = fileno(p_sys->p_file); + if (i_fd == -1) { CleanUp(p_sys); return VLC_EGENERIC; @@ -519,12 +513,13 @@ Open(vlc_object_t *p_this) * If HAVE_FLOCK is not defined, the running OS is most likely Windows * and a lock was already acquired when the file was opened. */ #ifdef HAVE_FLOCK - if (flock(p_sys->i_fd, LOCK_EX|LOCK_NB) != 0) + if (flock(i_fd, LOCK_EX|LOCK_NB) != 0) { CleanUp(p_sys); return VLC_EGENERIC; } #endif + p_sys->i_fd = i_fd; if (list_read(p_sys, &p_sys->list) != VLC_SUCCESS) {