rust


Jack audio client name longer than 4 characters breaks client


Trying to use the JACK-AUDIO-CONNECTION-KIT from Rust (documentation), I run into problems calling
jack_client_t* jack_client_open ( const char * client_name,
jack_options_t options,
jack_status_t * status,
... )
In Rust I use
#[link(name = "jack")]
extern "C" {
pub fn jack_client_open(name: *const libc::c_char,
options: JackOptions,
status: &JackStatus)
-> *mut JackClientT;
}
(complete code)
When I use a name with four characters it works, e.g.
let name = CString::new("yass").unwrap().as_ptr();
but if I use 5 or more characters it doesn't work. In the JACK docs linked to above, it says that the name can be at most int jack_client_name_size() characters long, which is 64 in my case. Why does this happen?
let name = CString::new("yass").unwrap().as_ptr(); allocates a string, gets a pointer to it... then throws away the string, so you get a use-after-free. Don't do this. Write let name = CString::new("yass").unwrap();, then use name.as_ptr(). See also CStr::as_ptr and this RFC proposal.
Any suggestions to improve the documentation would be welcome.

Related Links

How to encapsulate resources and their references in one struct in Rust? [duplicate]
How would one return a function from a function in Rust?
Lifetime on trait returning iterator
Mutable borrow of self doesn't change to immutable
How do I specify the linker path in Rust?
Are raw pointers to temporaries ok in Rust?
How to destructure tuple struct with reference
Unable to use std::process::Command to SSH - No such file or directory
“borrowed value does not live long enough” error in trie insertion
How to check for EOF in read_line in Rust 1.12?
Can I create an owned pointer to a stack object
How do I abort a Rust process?
Is it possible to disable Rust's lifetime elision?
How to implement Index over a wrapped HashMap?
Why is it allowed to pass the parameter value by reference with the duplicated sign &? [duplicate]
How to handle floating point exceptions (fpe) with Rust?

Categories

HOME
spring-data
artificial-intelligence
plesk
mpdf
windows-8.1
yahoo-weather-api
yii
swi-prolog
operating-system
initialization
sentry
firebase-dynamic-links
clickable-image
sap-fiori
android-externalstorage
mailmerge
sql-injection
pinterest
scheduled-tasks
coreldraw
maven-surefire-plugin
macromedia
iwebbrowser2
sendmessage
xenapp
delayed-job
rspec-rails
sql-execution-plan
rails-postgresql
busboy
cups
pdfnet
twilio-php
iscroll
imgur
jacoco-maven-plugin
opal-framework
vungle-ads
morphline
reverse-dns
zend-form
qvtkwidget
jgrapht
datediff
1010
case-when
kendo-editor
polymaps
rustdoc
p6spy
nunit-console
raw-sockets
static-methods
adp
highlighting
rails-engines
jsr363
android-expansion-files
webgrind
servicestack-bsd
json-spirit
largenumber
dsa
featuretoggle
embeddedwebserver
console.log
android-audiomanager
baseadapter
directorysearcher
zend-mail
iplimage
neo4jphp
thruway
radius-protocol
meteorite
colon
indesign-server
microformats
statechart
delphi-xe4
msinfo32
zotonic
multidrop-bus
servercontrol
play2-mini
getopts
3des
printqueue
asdoc
bucket
autobench
twitter-feed

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App