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 7169829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:05:23+00:00 2026-05-28T15:05:23+00:00

Hi I am getting the the following error from valgrind. Conditional move based on

  • 0

Hi I am getting the the following error from valgrind.

Conditional move based on uninitialized values, Uninitalized values was created by heap allocation.

The compiler does not complain.

I looked at most of the similar errors at stackoverflow, but I can’t seem to pinpoint what’s wrong with mine.

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>

    int
    main(void)
     {

      char *string1 = malloc(45);
      char string2[25] = "HELLO WORLD";
      strcpy(string1,string2);
      printf("String one is %s\n",string1);

      char string3[25];
      for (int i = 0; i < 25; i++)
       {
        string3[i] = tolower(string1[i]);

       }
      printf("The output is %s\n",string3);
      free(string1);
      return 0;

    }
  • 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-28T15:05:24+00:00Added an answer on May 28, 2026 at 3:05 pm

    You’re looping from 0 to 24 along string1, which has only been initialized strlen("HELLO WORLD") + 1 bytes. Bytes indexed from 12 to 24 there have not been initialized, and you shouldn’t be trying to read them. You should either use calloc() to allocate string1 or use memset() to initialize it, like so:

    char *string1 = calloc(1, 45);
    

    or

    char *string1 = malloc(45);
    memset(string1, 0, 45);
    

    Or you could initialize string3 to zeroes with the above methods and then only copy strlen(string1) bytes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following error from valgrind. Conditional jump or move depends on
I am getting the following error when I post back a page from the
I'm getting the following error whenever my code creates a DataTableReader from a valid
I am getting the following error when trying to update my project from Intellij
I have downloaded a web project from CodePlex and am getting the following error
I am getting a compile error from the following property. The error is: The
I'm getting the error message when running the following code from a C# console
I am getting the following error from some users while performing a lightweight Core
I am getting the following error from C++ Builder 2009's linker Unresolved external '__fastcall
I'm getting the following error from g++ while trying to add iterator support for

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.