File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ static bool BarMainLoginUser (BarApp_t *app) {
109109/* Run a password_command and return the result, or NULL on failure.
110110 * Caller must free the returned string.
111111 */
112- static char * BarRunPasswordCommand (BarSettings_t * settings , const char * cmd ) {
112+ static char * BarRunPasswordCommand (const BarSettings_t * settings , const char * cmd ) {
113113 pid_t chld ;
114114 int pipeFd [2 ];
115115 char passBuf [BAR_INPUT_MAX ];
@@ -166,7 +166,7 @@ static char *BarRunPasswordCommand (BarSettings_t *settings, const char *cmd) {
166166 * Sets acct->password if password_command succeeds.
167167 * @return true if password is available after resolution.
168168 */
169- static bool BarResolveAccountPassword (BarSettings_t * settings , BarAccount_t * acct ) {
169+ static bool BarResolveAccountPassword (const BarSettings_t * settings , BarAccount_t * acct ) {
170170 if (acct -> password != NULL ) return true;
171171 if (acct -> passwordCmd != NULL ) {
172172 acct -> password = BarRunPasswordCommand (settings , acct -> passwordCmd );
Original file line number Diff line number Diff line change @@ -771,11 +771,18 @@ void BarSettingsRead (BarSettings_t *settings) {
771771 char * colon = strchr (val , ':' );
772772 if (colon && colon != val && * (colon + 1 ) != '\0' ) {
773773 * colon = '\0' ;
774- accountLines = realloc (accountLines ,
774+ BarAccountLine_t * newLines = realloc (accountLines ,
775775 (accountLineCount + 1 ) * sizeof (BarAccountLine_t ));
776- accountLines [accountLineCount ].id = strdup (val );
777- accountLines [accountLineCount ].path = strdup (colon + 1 );
778- accountLineCount ++ ;
776+ if (newLines == NULL ) {
777+ BarUiMsg (settings , MSG_ERR ,
778+ "Out of memory reading account lines at %s:%zu\n" ,
779+ path , lineNum );
780+ } else {
781+ accountLines = newLines ;
782+ accountLines [accountLineCount ].id = strdup (val );
783+ accountLines [accountLineCount ].path = strdup (colon + 1 );
784+ accountLineCount ++ ;
785+ }
779786 } else {
780787 BarUiMsg (settings , MSG_INFO ,
781788 "Invalid account format at %s:%zu (expected id:path)\n" ,
You can’t perform that action at this time.
0 commit comments