Merge pull request #229 from rkta/null
Fix all warnings when building with -Wnull-dereference
This commit is contained in:
+2
-1
@@ -35,7 +35,8 @@ RC_DIR = @RC_DIR@
|
|||||||
ETC_DIR = $(sysconfdir)
|
ETC_DIR = $(sysconfdir)
|
||||||
CONF_DIR = $(sysconfdir)/$(PACKAGE)
|
CONF_DIR = $(sysconfdir)/$(PACKAGE)
|
||||||
|
|
||||||
CFLAGS = -Wall -I. -I$(top_srcdir) @CFLAGS@ $(CPPFLAGS) $(DEFS) $(OPTS)
|
WARNINGS= -Wall -Wnull-dereference
|
||||||
|
CFLAGS = $(WARNINGS) -I. -I$(top_srcdir) @CFLAGS@ $(CPPFLAGS) $(DEFS) $(OPTS)
|
||||||
WCCFLAGS = @WCCFLAGS@
|
WCCFLAGS = @WCCFLAGS@
|
||||||
CPPFLAGS = @CPPFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
DEFS = @DEFS@ -DAUXBIN_DIR=\"$(AUXBIN_DIR)\" \
|
DEFS = @DEFS@ -DAUXBIN_DIR=\"$(AUXBIN_DIR)\" \
|
||||||
|
|||||||
@@ -707,6 +707,7 @@ readBufferCache(Buffer *buf)
|
|||||||
|
|
||||||
cache = fopen(buf->savecache, "r");
|
cache = fopen(buf->savecache, "r");
|
||||||
if (cache == NULL || fread1(clnum, cache) || fread1(tlnum, cache)) {
|
if (cache == NULL || fread1(clnum, cache) || fread1(tlnum, cache)) {
|
||||||
|
if (cache != NULL)
|
||||||
fclose(cache);
|
fclose(cache);
|
||||||
buf->savecache = NULL;
|
buf->savecache = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1596,7 +1596,8 @@ file_to_url(char *file)
|
|||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
file = expandPath(file);
|
if (!(file = expandPath(file)))
|
||||||
|
return NULL;
|
||||||
#ifdef SUPPORT_NETBIOS_SHARE
|
#ifdef SUPPORT_NETBIOS_SHARE
|
||||||
if (file[0] == '/' && file[1] == '/') {
|
if (file[0] == '/' && file[1] == '/') {
|
||||||
char *p;
|
char *p;
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu)
|
|||||||
if (src)
|
if (src)
|
||||||
newBuf->header_source = tmpf;
|
newBuf->header_source = tmpf;
|
||||||
}
|
}
|
||||||
while ((tmp = StrmyUFgets(uf))->length) {
|
while ((tmp = StrmyUFgets(uf)) && tmp->length) {
|
||||||
#ifdef USE_NNTP
|
#ifdef USE_NNTP
|
||||||
if (uf->scheme == SCM_NEWS && tmp->ptr[0] == '.')
|
if (uf->scheme == SCM_NEWS && tmp->ptr[0] == '.')
|
||||||
Strshrinkfirst(tmp, 1);
|
Strshrinkfirst(tmp, 1);
|
||||||
@@ -1382,16 +1382,15 @@ AuthDigestCred(struct http_auth *ha, Str uname, Str pw, ParsedURL *pu,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = Strnew_m_charp("Digest username=\"", uname->ptr, "\"", NULL);
|
tmp = Strnew_m_charp("Digest username=\"", uname->ptr, "\"", NULL);
|
||||||
Strcat_m_charp(tmp, ", realm=",
|
if ((s = get_auth_param(ha->param, "realm")) != NULL)
|
||||||
get_auth_param(ha->param, "realm")->ptr, NULL);
|
Strcat_m_charp(tmp, ", realm=", s->ptr, NULL);
|
||||||
Strcat_m_charp(tmp, ", nonce=",
|
if ((s = get_auth_param(ha->param, "nonce")) != NULL)
|
||||||
get_auth_param(ha->param, "nonce")->ptr, NULL);
|
Strcat_m_charp(tmp, ", nonce=", s->ptr, NULL);
|
||||||
Strcat_m_charp(tmp, ", uri=\"", uri->ptr, "\"", NULL);
|
Strcat_m_charp(tmp, ", uri=\"", uri->ptr, "\"", NULL);
|
||||||
Strcat_m_charp(tmp, ", response=\"", rd->ptr, "\"", NULL);
|
Strcat_m_charp(tmp, ", response=\"", rd->ptr, "\"", NULL);
|
||||||
|
|
||||||
if (algorithm)
|
if (algorithm && (s = get_auth_param(ha->param, "algorithm")))
|
||||||
Strcat_m_charp(tmp, ", algorithm=",
|
Strcat_m_charp(tmp, ", algorithm=", s->ptr, NULL);
|
||||||
get_auth_param(ha->param, "algorithm")->ptr, NULL);
|
|
||||||
|
|
||||||
if (cnonce)
|
if (cnonce)
|
||||||
Strcat_m_charp(tmp, ", cnonce=\"", cnonce->ptr, "\"", NULL);
|
Strcat_m_charp(tmp, ", cnonce=\"", cnonce->ptr, "\"", NULL);
|
||||||
@@ -3105,11 +3104,14 @@ purgeline(struct html_feed_environ *h_env)
|
|||||||
{
|
{
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
Str tmp;
|
Str tmp;
|
||||||
|
TextLine *tl;
|
||||||
|
|
||||||
if (h_env->buf == NULL || h_env->blank_lines == 0)
|
if (h_env->buf == NULL || h_env->blank_lines == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p = rpopTextLine(h_env->buf)->line->ptr;
|
if (!(tl = rpopTextLine(h_env->buf)))
|
||||||
|
return;
|
||||||
|
p = tl->line->ptr;
|
||||||
tmp = Strnew();
|
tmp = Strnew();
|
||||||
while (*p) {
|
while (*p) {
|
||||||
q = p;
|
q = p;
|
||||||
@@ -6332,7 +6334,7 @@ file_feed()
|
|||||||
{
|
{
|
||||||
Str s;
|
Str s;
|
||||||
s = StrISgets(_file_lp2);
|
s = StrISgets(_file_lp2);
|
||||||
if (s->length == 0) {
|
if (s && s->length == 0) {
|
||||||
ISclose(_file_lp2);
|
ISclose(_file_lp2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -7351,7 +7353,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
|
|||||||
#endif
|
#endif
|
||||||
if (IStype(f->stream) != IST_ENCODED)
|
if (IStype(f->stream) != IST_ENCODED)
|
||||||
f->stream = newEncodedStream(f->stream, f->encoding);
|
f->stream = newEncodedStream(f->stream, f->encoding);
|
||||||
while ((lineBuf2 = StrmyUFgets(f))->length) {
|
while ((lineBuf2 = StrmyUFgets(f)) && lineBuf2->length) {
|
||||||
#ifdef USE_NNTP
|
#ifdef USE_NNTP
|
||||||
if (f->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') {
|
if (f->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') {
|
||||||
Strshrinkfirst(lineBuf2, 1);
|
Strshrinkfirst(lineBuf2, 1);
|
||||||
@@ -7508,7 +7510,7 @@ loadGopherDir0(URLFile *uf, ParsedURL *pu)
|
|||||||
|
|
||||||
pre = 0;
|
pre = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (lbuf = StrUFgets(uf), lbuf->length == 0)
|
if (!(lbuf = StrUFgets(uf)) || lbuf->length == 0)
|
||||||
break;
|
break;
|
||||||
if (lbuf->ptr[0] == '.' &&
|
if (lbuf->ptr[0] == '.' &&
|
||||||
(lbuf->ptr[1] == '\n' || lbuf->ptr[1] == '\r'))
|
(lbuf->ptr[1] == '\n' || lbuf->ptr[1] == '\r'))
|
||||||
@@ -7678,7 +7680,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf)
|
|||||||
nlines = 0;
|
nlines = 0;
|
||||||
if (IStype(uf->stream) != IST_ENCODED)
|
if (IStype(uf->stream) != IST_ENCODED)
|
||||||
uf->stream = newEncodedStream(uf->stream, uf->encoding);
|
uf->stream = newEncodedStream(uf->stream, uf->encoding);
|
||||||
while ((lineBuf2 = StrmyISgets(uf->stream))->length) {
|
while ((lineBuf2 = StrmyISgets(uf->stream)) && lineBuf2->length) {
|
||||||
#ifdef USE_NNTP
|
#ifdef USE_NNTP
|
||||||
if (uf->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') {
|
if (uf->scheme == SCM_NEWS && lineBuf2->ptr[0] == '.') {
|
||||||
Strshrinkfirst(lineBuf2, 1);
|
Strshrinkfirst(lineBuf2, 1);
|
||||||
@@ -8102,7 +8104,8 @@ getNextPage(Buffer *buf, int plen)
|
|||||||
|
|
||||||
init_stream(&uf, SCM_UNKNOWN, NULL);
|
init_stream(&uf, SCM_UNKNOWN, NULL);
|
||||||
for (i = 0; i < plen; i++) {
|
for (i = 0; i < plen; i++) {
|
||||||
lineBuf2 = StrmyISgets(buf->pagerSource);
|
if (!(lineBuf2 = StrmyISgets(buf->pagerSource)))
|
||||||
|
return NULL;
|
||||||
if (lineBuf2->length == 0) {
|
if (lineBuf2->length == 0) {
|
||||||
/* Assume that `cmd == buf->filename' */
|
/* Assume that `cmd == buf->filename' */
|
||||||
if (buf->filename)
|
if (buf->filename)
|
||||||
@@ -8151,6 +8154,7 @@ getNextPage(Buffer *buf, int plen)
|
|||||||
l = l->next;
|
l = l->next;
|
||||||
} while (l && l->bpos);
|
} while (l && l->bpos);
|
||||||
buf->firstLine = l;
|
buf->firstLine = l;
|
||||||
|
if (l)
|
||||||
buf->firstLine->prev = NULL;
|
buf->firstLine->prev = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level,
|
|||||||
!strcasecmp(frame.body->type, "text/plain")) {
|
!strcasecmp(frame.body->type, "text/plain")) {
|
||||||
Str tmp;
|
Str tmp;
|
||||||
fprintf(f1, "<pre>\n");
|
fprintf(f1, "<pre>\n");
|
||||||
while ((tmp = StrmyUFgets(&f2))->length) {
|
while ((tmp = StrmyUFgets(&f2)) && tmp->length) {
|
||||||
tmp = convertLine(NULL, tmp, HTML_MODE, &charset,
|
tmp = convertLine(NULL, tmp, HTML_MODE, &charset,
|
||||||
doc_charset);
|
doc_charset);
|
||||||
fprintf(f1, "%s", html_quote(tmp->ptr));
|
fprintf(f1, "%s", html_quote(tmp->ptr));
|
||||||
@@ -549,7 +549,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level,
|
|||||||
do {
|
do {
|
||||||
if (*p == '\0') {
|
if (*p == '\0') {
|
||||||
Str tmp = StrmyUFgets(&f2);
|
Str tmp = StrmyUFgets(&f2);
|
||||||
if (tmp->length == 0)
|
if (!tmp || tmp->length == 0)
|
||||||
break;
|
break;
|
||||||
tmp = convertLine(NULL, tmp, HTML_MODE, &charset,
|
tmp = convertLine(NULL, tmp, HTML_MODE, &charset,
|
||||||
doc_charset);
|
doc_charset);
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ ftp_command(FTP ftp, char *cmd, char *arg, int *status)
|
|||||||
if (!status)
|
if (!status)
|
||||||
return NULL;
|
return NULL;
|
||||||
*status = -1; /* error */
|
*status = -1; /* error */
|
||||||
tmp = StrISgets(ftp->rf);
|
if (!(tmp = StrISgets(ftp->rf)))
|
||||||
|
return NULL;
|
||||||
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
||||||
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ')
|
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ')
|
||||||
sscanf(tmp->ptr, "%d", status);
|
sscanf(tmp->ptr, "%d", status);
|
||||||
@@ -87,7 +88,8 @@ ftp_command(FTP ftp, char *cmd, char *arg, int *status)
|
|||||||
* with the same code, followed immediately by Space <SP>,
|
* with the same code, followed immediately by Space <SP>,
|
||||||
* optionally some text, and the Telnet end-of-line code. */
|
* optionally some text, and the Telnet end-of-line code. */
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = StrISgets(ftp->rf);
|
if (!(tmp = StrISgets(ftp->rf)))
|
||||||
|
break;
|
||||||
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
||||||
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ') {
|
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ') {
|
||||||
sscanf(tmp->ptr, "%d", status);
|
sscanf(tmp->ptr, "%d", status);
|
||||||
|
|||||||
@@ -1079,6 +1079,10 @@ main(int argc, char **argv)
|
|||||||
newbuf->search_header = search_header;
|
newbuf->search_header = search_header;
|
||||||
if (CurrentTab == NULL) {
|
if (CurrentTab == NULL) {
|
||||||
FirstTab = LastTab = CurrentTab = newTab();
|
FirstTab = LastTab = CurrentTab = newTab();
|
||||||
|
if (!FirstTab) {
|
||||||
|
fprintf(stderr, "%s\n","Can't allocated memory");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
nTab = 1;
|
nTab = 1;
|
||||||
Firstbuf = Currentbuf = newbuf;
|
Firstbuf = Currentbuf = newbuf;
|
||||||
}
|
}
|
||||||
@@ -6481,7 +6485,7 @@ followTab(TabBuffer * tab)
|
|||||||
Buffer *c, *p;
|
Buffer *c, *p;
|
||||||
|
|
||||||
c = Currentbuf;
|
c = Currentbuf;
|
||||||
p = prevBuffer(c, buf);
|
if ((p = prevBuffer(c, buf)))
|
||||||
p->nextBuffer = NULL;
|
p->nextBuffer = NULL;
|
||||||
Firstbuf = buf;
|
Firstbuf = buf;
|
||||||
deleteTab(CurrentTab);
|
deleteTab(CurrentTab);
|
||||||
@@ -6522,7 +6526,7 @@ tabURL0(TabBuffer * tab, char *prompt, int relative)
|
|||||||
Buffer *c, *p;
|
Buffer *c, *p;
|
||||||
|
|
||||||
c = Currentbuf;
|
c = Currentbuf;
|
||||||
p = prevBuffer(c, buf);
|
if ((p = prevBuffer(c, buf)))
|
||||||
p->nextBuffer = NULL;
|
p->nextBuffer = NULL;
|
||||||
Firstbuf = buf;
|
Firstbuf = buf;
|
||||||
deleteTab(CurrentTab);
|
deleteTab(CurrentTab);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ news_command(News * news, char *cmd, char *arg, int *status)
|
|||||||
return NULL;
|
return NULL;
|
||||||
*status = -1;
|
*status = -1;
|
||||||
tmp = StrISgets(news->rf);
|
tmp = StrISgets(news->rf);
|
||||||
if (tmp->length)
|
if (tmp && tmp->length)
|
||||||
sscanf(tmp->ptr, "%d", status);
|
sscanf(tmp->ptr, "%d", status);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,8 @@ loadNewsgroup0(ParsedURL *pu)
|
|||||||
if (status == 224) {
|
if (status == 224) {
|
||||||
f.scheme = SCM_NEWS;
|
f.scheme = SCM_NEWS;
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = StrISgets(current_news.rf);
|
if (!(tmp = StrISgets(current_news.rf)))
|
||||||
|
break;
|
||||||
if (NEWS_ENDLINE(tmp->ptr))
|
if (NEWS_ENDLINE(tmp->ptr))
|
||||||
break;
|
break;
|
||||||
if (sscanf(tmp->ptr, "%d", &i) != 1)
|
if (sscanf(tmp->ptr, "%d", &i) != 1)
|
||||||
@@ -443,7 +444,7 @@ loadNewsgroup0(ParsedURL *pu)
|
|||||||
continue;
|
continue;
|
||||||
if (*p == '<')
|
if (*p == '<')
|
||||||
p++;
|
p++;
|
||||||
if (!(q = strchr(p, '>')) && !(q = strchr(p, '\t')))
|
if ((q = strchr(p, '>')) || (q = strchr(p, '\t')))
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
if (!(s = checkHeader(buf, "Subject:")))
|
if (!(s = checkHeader(buf, "Subject:")))
|
||||||
continue;
|
continue;
|
||||||
@@ -474,7 +475,8 @@ loadNewsgroup0(ParsedURL *pu)
|
|||||||
if (status != 215)
|
if (status != 215)
|
||||||
goto news_end;
|
goto news_end;
|
||||||
while (1) {
|
while (1) {
|
||||||
tmp = StrISgets(current_news.rf);
|
if (!(tmp = StrISgets(current_news.rf)))
|
||||||
|
break;
|
||||||
if (NEWS_ENDLINE(tmp->ptr))
|
if (NEWS_ENDLINE(tmp->ptr))
|
||||||
break;
|
break;
|
||||||
if (flag < 2) {
|
if (flag < 2) {
|
||||||
|
|||||||
+4
-2
@@ -426,11 +426,13 @@ fb_frame_new(int w, int h, int n)
|
|||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
frame[i] = fb_image_new(w, h);
|
frame[i] = fb_image_new(w, h);
|
||||||
|
if (frame[i] == NULL) {
|
||||||
|
error = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
frame[i]->num = n;
|
frame[i]->num = n;
|
||||||
frame[i]->id = i;
|
frame[i]->id = i;
|
||||||
frame[i]->delay = 1000;
|
frame[i]->delay = 1000;
|
||||||
if (frame[i] == NULL)
|
|
||||||
error = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ draw(FB_IMAGE * img, Imlib_Image image)
|
|||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
data = imlib_image_get_data_for_reading_only();
|
data = imlib_image_get_data_for_reading_only();
|
||||||
|
|
||||||
|
if (data == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
for (j = 0; j < img->height; j++) {
|
for (j = 0; j < img->height; j++) {
|
||||||
offset = img->width * j;
|
offset = img->width * j;
|
||||||
for (i = 0; i < img->width; i++) {
|
for (i = 0; i < img->width; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user