Comments (3)
Hello,
the tmporig
pointer has moved in this snippet
while (count--) {
ins = strstr(tmporig, rep);
len_front = ins - tmporig;
tmp = strncpy(tmp, tmporig, len_front) + len_front;
tmp = strcpy(tmp, with) + len_with;
tmporig += len_front + len_rep; // move to next "end of rep"
}
hence the free(tmporig);
doesn't work since tmporig
doesn't point to the start of the buffer.
Since the buffer pointed by orig
parameter is not modified inside the function, there is no need to duplicate it.
So, instead of doing
char *tmporig = malloc(strlen(orig) + 1); // Copy of orig that we work with
tmporig = strcpy(tmporig, orig);
it should be enough doing instead
char *tmporig = orig;
so there is no need to perform a free()
in the end, and no memory leak is created.
from pacparser.
Good catch, @fralken. My C-foo is pretty rusty now, but we don't really need to even create a copy of orig, right? We could simply use orig; it won't modify the underlying string
from pacparser.
Indeed you are right @manugarg since orig
itself is a copy of the pointer to the input string.
from pacparser.
Related Issues (20)
- Getting a standalone Pactester exe on Windows or Unix
- spidermonkey makefile causes error in the clean target
- Potential security issue
- Failed to compile on Windows 10 64-bit HOT 3
- ./python39.dll: file not recognized: File format not recognized collect2.exe: error: ld returned 1 exit status Makefile.win32:59: recipe for target '_pacparser39.pyd' failed HOT 2
- isResolvable() returns true for some ip's but not others HOT 2
- any methods to print log in the .pac file?
- PIP package for Python 3.6 HOT 1
- PIP install error HOT 5
- Python 3.11 Compatibility HOT 2
- Set up permissions to build.yml HOT 3
- Compiling and using as static lib HOT 2
- Hash pin github workflow dependencies HOT 2
- issue for read_file_into_str in pacparser.c HOT 4
- Cross Compilation issue
- pacparser_setmyip leaks memory HOT 5
- Package in Debian HOT 1
- docker usage HOT 1
- pip install pacparser with python3.12 on Fedora 39 fails HOT 2
- Build failure with gcc 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pacparser.