Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the replacement string size is not equal to the needle size zrepstr overwrites other charecters #7

Open
rilysh opened this issue Jun 21, 2023 · 0 comments

Comments

@rilysh
Copy link

rilysh commented Jun 21, 2023

Hello,

If the replacement string size (y) is not equal to the needle size (x) zrepstr(...) function overwrites other characters.

For example,

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

#include "zrepstr.h"

int main()
{
    char str[50] = {0};

    snprintf(str, sizeof(str), "My simple text message");
    zrepstr(str, "text", "more than text");
    fprintf(stdout, "%s\n", str);
}

Where "more than text" overwrite the "message" string and it becomes something like this, "My simple more than te".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant