Project

General

Profile

Actions

Bug #4177

closed

Rustc nightly warning getting the inner pointer of a temporary `CString`

Added by Philippe Antoine over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
Affected Versions:
Effort:
Difficulty:
Label:
Needs backport, Needs backport to 4.1, Needs backport to 5.0, Needs backport to 6.0

Description

My compiler is rustc 1.50.0-nightly (603ab5bd6 2020-11-15)

The full warning text is

warning: getting the inner pointer of a temporary `CString`
  --> src/conf.rs:38:47
   |
38 |         if ConfGet(CString::new(key).unwrap().as_ptr(), &mut vptr) != 1 {
   |                    -------------------------- ^^^^^^ this pointer will be invalid
   |                    |
   |                    this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
   |
   = note: `#[warn(temporary_cstring_as_ptr)]` on by default
   = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
   = help: for more information, see https://doc.rust-lang.org/reference/destructors.html


Related issues 2 (0 open2 closed)

Copied to Suricata - Bug #4188: Rustc nightly warning getting the inner pointer of a temporary `CString`ClosedVictor JulienActions
Copied to Suricata - Bug #4189: Rustc nightly warning getting the inner pointer of a temporary `CString`ClosedShivani BhardwajActions
Actions #2

Updated by Philippe Antoine over 3 years ago

  • Target version set to 6.0.1
Actions #3

Updated by Philippe Antoine over 3 years ago

  • Affected Versions 6.0.0 added
  • Affected Versions deleted (6.0.1)
Actions #4

Updated by Philippe Antoine over 3 years ago

  • Status changed from In Review to Closed
Actions #5

Updated by Shivani Bhardwaj over 3 years ago

  • Copied to Bug #4188: Rustc nightly warning getting the inner pointer of a temporary `CString` added
Actions #6

Updated by Shivani Bhardwaj over 3 years ago

  • Copied to Bug #4189: Rustc nightly warning getting the inner pointer of a temporary `CString` added
Actions

Also available in: Atom PDF