-
Notifications
You must be signed in to change notification settings - Fork 168
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
Alloc fail & fix compile warning #105
Changes from 3 commits
4b7cacc
dde246d
4a652e7
b7c7859
5a787dc
701e136
6a29214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,8 +112,9 @@ bool qsocket_close(int sockfd, int timeoutms) { | |
char buf[1024]; | ||
while (true) { | ||
ssize_t read = qio_read(sockfd, buf, sizeof(buf), timeoutms); | ||
DEBUG("Throw %zu bytes from dummy input stream.", read); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems the indentation is not lined up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. qlibc uses spaces, please ignore using tabs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, didn't realize that, thanks for the heads up. Fixed |
||
if (read <= 0) | ||
break;DEBUG("Throw %zu bytes from dummy input stream.", read); | ||
break; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,9 @@ char *qstrreplace(const char *mode, char *srcstr, const char *tokstr, | |
if (method == 't') { /* Token replace */ | ||
maxstrlen = strlen(srcstr) * ((strlen(word) > 0) ? strlen(word) : 1); | ||
newstr = (char *) malloc(maxstrlen + 1); | ||
if (newstr == NULL) | ||
return NULL; | ||
|
||
|
||
for (srcp = (char *) srcstr, newp = newstr; *srcp; srcp++) { | ||
for (tokenp = (char *) tokstr; *tokenp; tokenp++) { | ||
|
@@ -274,6 +277,9 @@ char *qstrreplace(const char *mode, char *srcstr, const char *tokstr, | |
maxstrlen = strlen(srcstr); | ||
} | ||
newstr = (char *) malloc(maxstrlen + 1); | ||
if (newstr == NULL) | ||
return NULL; | ||
|
||
tokstrlen = strlen(tokstr); | ||
|
||
for (srcp = srcstr, newp = newstr; *srcp; srcp++) { | ||
|
@@ -389,6 +395,9 @@ char *qstrdup_between(const char *str, const char *start, const char *end) { | |
int len = e - s; | ||
|
||
char *buf = (char *) malloc(sizeof(char) * (len + 1)); | ||
if (buf == NULL) | ||
return NULL; | ||
|
||
strncpy(buf, s, len); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can update this to memcpy() as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM. How about using qmemdup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your right. I'll change to memcpy. |
||
buf[len] = '\0'; | ||
|
||
|
@@ -869,6 +878,7 @@ char *qstr_conv_encoding(const char *str, const char *fromcode, | |
char *tostr = (char *) malloc(tosize); | ||
if (tostr == NULL) | ||
return NULL; | ||
|
||
char *tostr1 = tostr; | ||
|
||
iconv_t it = iconv_open(tocode, fromcode); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this line please? I'd prefer not to mix the change in this PR.