Skip to content

Commit

Permalink
write/line: inline dirs/files must not be empty
Browse files Browse the repository at this point in the history
Because DWARF version 4 uses these as a terminator.
  • Loading branch information
philipc committed Jan 28, 2019
1 parent df347fd commit e59bd5a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/write/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ impl LineProgram {
/// # Panics
///
/// Panics if `line_base` > 0.
///
/// Panics if `line_base` + `line_range` <= 0.
///
/// Panics if `comp_dir` is empty or contains a null byte.
///
/// Panics if `comp_file` is empty or contains a null byte.
#[allow(clippy::too_many_arguments)]
#[allow(clippy::new_ret_no_self)]
pub fn new(
Expand Down Expand Up @@ -234,9 +239,10 @@ impl LineProgram {
///
/// # Panics
///
/// Panics if `directory` contains a null byte.
/// Panics if `directory` is empty or contains a null byte.
pub fn add_directory(&mut self, directory: LineString) -> DirectoryId {
if let LineString::String(ref val) = directory {
assert!(!val.is_empty());
assert!(!val.contains(&0));
}
let (index, _) = self.directories.insert_full(directory);
Expand Down Expand Up @@ -268,14 +274,15 @@ impl LineProgram {
///
/// # Panics
///
/// Panics if 'file' contain a null byte.
/// Panics if 'file' is empty or contains a null byte.
pub fn add_file(
&mut self,
file: LineString,
directory: DirectoryId,
info: Option<FileInfo>,
) -> FileId {
if let LineString::String(ref val) = file {
assert!(!val.is_empty());
assert!(!val.contains(&0));
}

Expand Down

0 comments on commit e59bd5a

Please sign in to comment.