Re: GString problem.
- From: Pawel Salek <pawsa TheoChem kth se>
- To: Archit Baweja <bighead crosswinds net>
- Cc: gnome-devel-list gnome org
- Subject: Re: GString problem.
- Date: Mon, 26 Mar 2001 10:38:04 +0200
On 2001-03-25 05:19 Archit Baweja wrote:
> static gint
> file_load (PeacockFile *file)
> {
> FILE *fp;
> gchar buffer[32];
> gint bytes_read;
> GString *data;
>
> /*
> * Open file for reading and if a problem occurs, return an
> error code.
> */
> fp = fopen (file->name, "r");
> g_return_val_if_fail (fp != NULL, -1);
>
> data = g_string_new ("");
>
> while (1) {
> bytes_read = fread (buffer, sizeof (gchar), 32, fp);
This code will crash if someone has compiled GLib with G_DISABLE_CHECKS.
You should replace g_return_val_if_fail (fp != NULL, -1); with
if(!fp) return -1;
and similar tests.
/Pawel
--
Pawel Salek (pawsa theochem kth se) http://www.theochem.kth.se/~pawsa/
Theoretical Chemistry Division, KTH voice: +46 8 790-8202
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]