codec: fix codec description potential null ptr issue
Codecs may not have .long_name initialized. Issue raised by Pilyushkin in #34.
This commit is contained in:
parent
ae06272af1
commit
6f0a14ee8b
@ -41,7 +41,14 @@ impl Codec {
|
||||
}
|
||||
|
||||
pub fn description(&self) -> &str {
|
||||
unsafe { from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).long_name).to_bytes()) }
|
||||
unsafe {
|
||||
let long_name = (*self.as_ptr()).long_name;
|
||||
if long_name.is_null() {
|
||||
""
|
||||
} else {
|
||||
from_utf8_unchecked(CStr::from_ptr(long_name).to_bytes())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn medium(&self) -> media::Type {
|
||||
|
Loading…
x
Reference in New Issue
Block a user