WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
d595ebd8
Commit
d595ebd8
authored
May 31, 2013
by
Mathias Bavay
Browse files
small fixes following a scan by Flawfinder
parent
314a24e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
meteoio/MessageBoxX11.cc
View file @
d595ebd8
...
...
@@ -36,8 +36,8 @@ void MessageBoxX11( const char* title, const char* text ) {
const
char
*
wmDeleteWindow
=
"WM_DELETE_WINDOW"
;
/* Open a display */
Display
*
dpy
;
if
(
!
(
dpy
=
XOpenDisplay
(
0
))
)
return
;
Display
*
dpy
=
XOpenDisplay
(
0
)
;
if
(
!
dpy
)
return
;
/* Get us a white and black color */
const
int
black
=
BlackPixel
(
dpy
,
DefaultScreen
(
dpy
)
);
...
...
@@ -67,24 +67,23 @@ void MessageBoxX11( const char* title, const char* text ) {
/* Split the text down into a list of lines */
char
**
strvec
=
NULL
;
size_t
strvec_size
=
0
;
char
*
temp
=
(
char
*
)
malloc
(
strlen
(
text
)
+
1
);
strcpy
(
temp
,
text
);
size_t
strvec_size
=
0
,
text_len
=
strlen
(
text
)
+
1
;
char
*
temp
=
(
char
*
)
malloc
(
text_len
);
str
n
cpy
(
temp
,
text
,
text_len
);
char
*
pch
=
strtok
(
temp
,
"
\n
"
);
while
(
pch
!=
NULL
)
{
strvec
=
(
char
**
)
realloc
(
strvec
,
(
strvec_size
+
1
)
*
sizeof
(
char
**
)
);
strvec
[
strvec_size
]
=
(
char
*
)
malloc
(
strlen
(
pch
)
+
1
);
strcpy
(
strvec
[
strvec_size
],
pch
);
str
n
cpy
(
strvec
[
strvec_size
],
pch
,
strlen
(
pch
)
+
1
);
++
strvec_size
;
pch
=
strtok
(
NULL
,
"
\n
"
);
}
free
(
temp
);
/* Compute the printed length and height of the longest and the tallest line */
XFontStruct
*
font
;
if
(
!
(
font
=
XQueryFont
(
dpy
,
XGContextFromGC
(
gc
)
))
)
return
;
XFontStruct
*
font
=
XQueryFont
(
dpy
,
XGContextFromGC
(
gc
));
if
(
!
font
)
return
;
int
length
=
0
,
height
=
0
,
direction
,
ascent
,
descent
;
XCharStruct
overall
;
...
...
meteoio/plugins/ARPSIO.cc
View file @
d595ebd8
...
...
@@ -508,7 +508,7 @@ void ARPSIO::moveToMarker(const std::string& marker)
char
dummy
[
ARPS_MAX_LINE_LENGTH
];
int
nb_elems
=
0
;
do
{
nb_elems
=
fscanf
(
fin
,
" %[^
\t\n
] "
,
dummy
);
nb_elems
=
fscanf
(
fin
,
" %[^
\t\n
] "
,
dummy
);
//HACK: possible buffer overflow
}
while
(
!
feof
(
fin
)
&&
strcmp
(
dummy
,
marker
.
c_str
())
!=
0
&&
nb_elems
!=
0
);
if
(
feof
(
fin
))
{
cleanup
();
...
...
meteoio/plugins/GRIBIO.cc
View file @
d595ebd8
...
...
@@ -212,10 +212,10 @@ void GRIBIO::addStation(const std::string& coord_spec, std::vector<Coords> &vecP
void
GRIBIO
::
listKeys
(
grib_handle
**
h
,
const
std
::
string
&
filename
)
{
const
unsigned
int
MAX_VAL_LEN
=
1024
;
//max value string length in GRIB
unsigned
long
key_iterator_filter_flags
=
GRIB_KEYS_ITERATOR_ALL_KEYS
;
char
*
name_space
=
NULL
;
grib_keys_iterator
*
kiter
=
grib_keys_iterator_new
(
*
h
,
key_iterator_filter_flags
,
name_space
);
const
unsigned
int
MAX_VAL_LEN
=
1024
;
//max value string length in GRIB
unsigned
long
key_iterator_filter_flags
=
GRIB_KEYS_ITERATOR_ALL_KEYS
;
char
*
name_space
=
NULL
;
grib_keys_iterator
*
kiter
=
grib_keys_iterator_new
(
*
h
,
key_iterator_filter_flags
,
name_space
);
if
(
!
kiter
)
{
cleanup
();
...
...
@@ -224,10 +224,9 @@ void GRIBIO::listKeys(grib_handle** h, const std::string& filename)
//Iterating over all keys
while
(
grib_keys_iterator_next
(
kiter
))
{
char
value
[
MAX_VAL_LEN
];
size_t
vlen
=
MAX_VAL_LEN
;
const
char
*
name
=
grib_keys_iterator_get_name
(
kiter
);
vlen
=
MAX_VAL_LEN
;
char
value
[
MAX_VAL_LEN
];
size_t
vlen
=
MAX_VAL_LEN
;
bzero
(
value
,
vlen
);
GRIB_CHECK
(
grib_get_string
(
*
h
,
name
,
value
,
&
vlen
),
name
);
std
::
cerr
<<
name
<<
" = "
<<
value
<<
"
\n
"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment