Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:22:50+00:00 2026-05-29T09:22:50+00:00

So, I’m new to C and i’ve been trying to write this tool to

  • 0

So, I’m new to C and i’ve been trying to write this tool to edit the id3 tags on music files from the command line. I’ve been getting this error:

* glibc detected double free or corruption (top): 0x0000000000502010 **

From what I’ve read, I know it has something to do with freeing up memory. I’m just not really sure where to go from here, though. Anyway, my logic was that if a tag existed I’d read that tag in, then make whatever changes needed to be made from the fields specified in the command line. Here’s the block that’s been giving me trouble. Thanks for any insight in advance!

    fopen(argv[1], "rb");
    fseek(in_file, -128, SEEK_END);
    fread(&tagTest, sizeof(struct iD3Tag), 1, in_file);
    fclose(in_file);

    for (x = 2; x < argc-1; x++)
    {            
        if (strcmp(argv[x], "-title"))
            strncpy(tagTest.title, argv[x+1], 30);
        if (strcmp(argv[x], "-artist"))
            strncpy(tagTest.artist, argv[x+1], 30);
        if (strcmp(argv[x], "-album"))
            strncpy(tagTest.album, argv[x+1], 30);
        if (strcmp(argv[x], "-year"))
            strncpy(tagTest.year, argv[x+1], 4);
        if (strcmp(argv[x], "-comment"))
            strncpy(tagTest.comment, argv[x+1], 28);
        if (strcmp(argv[x], "-track"))
            tagTest.track = atoi(argv[x+1]);
    }

    tagTest.seperator = 0;

    fopen(argv[1], "r+b");
    fseek(in_file, -128, SEEK_END);
    fwrite(&tagTest, sizeof(struct iD3Tag), 1, in_file);
    fclose(in_file);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:22:52+00:00Added an answer on May 29, 2026 at 9:22 am

    There are no free calls in this code, so I presume you’re happy you’re not double-freeing anything? Therefore, I presume you have some heap corruption here. I.e. you’re writing more data into the tag than there is space for.

    First, to address the point from @H2CO3, I don’t believe that’s the problem here. It might be that the problem he mentions does exist – in which case you’ll corrupt your datafile – but it doesn’t look like that’s the cause of the program failure.

    I think your real problem is that you never assign anything to in_file! I think you need:

    in_file = fopen (argv[1], "rb");
    

    Some other comments:

    • strcmp returns zero (false) when a string matches and non-zero (true) when it does not match … so all your compares appear broken – that shouldn’t cause corruption.
    • The loop appears to check the argument values as well as switches – you should skip those.
    • There’s no need to open the file twice – you can open it for both read and write at the start.
    • You need to put a lot more error checking in in case the file doesn’t exist or isn’t what you expect – but then I’m sure you knew that.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.