mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	buf.c: correctly handle unset environment variables
This commit is contained in:
		
							parent
							
								
									71c8aa1361
								
							
						
					
					
						commit
						aa4668c792
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		| 
						 | 
					@ -20,10 +20,9 @@ buf_expand_shell_variables(struct buf *s)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			*p = '\0';
 | 
								*p = '\0';
 | 
				
			||||||
			p = getenv(environment_variable.buf);
 | 
								p = getenv(environment_variable.buf);
 | 
				
			||||||
			if (!p) {
 | 
								if (p) {
 | 
				
			||||||
				goto out;
 | 
									buf_add(&new, p);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			buf_add(&new, p);
 | 
					 | 
				
			||||||
			i += strlen(environment_variable.buf);
 | 
								i += strlen(environment_variable.buf);
 | 
				
			||||||
		} else if (s->buf[i] == '~') {
 | 
							} else if (s->buf[i] == '~') {
 | 
				
			||||||
			/* expand tilde */
 | 
								/* expand tilde */
 | 
				
			||||||
| 
						 | 
					@ -38,7 +37,6 @@ buf_expand_shell_variables(struct buf *s)
 | 
				
			||||||
			new.buf[new.len] = '\0';
 | 
								new.buf[new.len] = '\0';
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
out:
 | 
					 | 
				
			||||||
	free(environment_variable.buf);
 | 
						free(environment_variable.buf);
 | 
				
			||||||
	free(s->buf);
 | 
						free(s->buf);
 | 
				
			||||||
	s->buf = new.buf;
 | 
						s->buf = new.buf;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue