Thread: Would this cause a core on Linux

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    58

    Would this cause a core on Linux

    Code:
    struct TMP  *tmp
    char *buf_ptr;
    
    
    buf_ptr = tmp->tr[i].ch_ptr;
    tmp->tr[i].ch_ptr = NULL

    tmp is a pointer to a struct TMP and tr is another pointer to another struct within tmp.


    Thanks

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Well, either "tmp" or "tmp->tr" is invalid. Post a compilable example that demonstrates the error.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    tmp is uninitialized pointer, it means it contains garbage
    so what happens when accessing
    Code:
    tmp->tr
    is undefined. Anything could happen
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. couple of questions concerning multi core cpu's
    By Masterx in forum Tech Board
    Replies: 6
    Last Post: 10-07-2009, 10:39 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. Porting from VC6 to Linux Fedora core 5
    By g4j31a5 in forum C++ Programming
    Replies: 17
    Last Post: 08-08-2006, 01:59 AM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM