Bug 235733 - g_utf8_validate() failed to allocate 4294967296 bytes
Summary: g_utf8_validate() failed to allocate 4294967296 bytes
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 6
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-09 20:24 UTC by Olivier Fourdan
Modified: 2007-11-30 22:12 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2007-04-10 05:47:25 UTC


Attachments (Terms of Use)

Description Olivier Fourdan 2007-04-09 20:24:02 UTC
Description of problem:

Using g_utf8_validate() with param length set as -1 cause the following terror
on x86_64:

GLib-ERROR **: gmem.c:172: failed to allocate 4294967296 bytes

Looks like -1 is interpreted as an unsigned, thus the 4294967296

The API of g_utf8_validate() says: 

max_len : 	 max bytes to validate, or -1 to go until NUL

[1]
http://developer.gnome.org/doc/API/2.0/glib/glib-Unicode-Manipulation.html#g-utf8-validate

Version-Release number of selected component (if applicable):

gcc-4.1.1-51.fc6
glib2-2.12.9-1.fc6
glib2-2.12.9-1.fc6

How reproducible:


Steps to Reproduce:
Just use the following call in  g_utf8_validate (string, -1, NULL)
  
Actual results:


Expected results:


Additional info:

This works as expected on other x86_64 distributions like Ubuntu or Debian.

Comment 1 Olivier Fourdan 2007-04-10 05:47:25 UTC
Never mind, I cannot reproduce that problem with a simple test case, so it's
something else. Sorry for the false alarm...

Comment 2 Jakub Jelinek 2007-04-13 10:49:46 UTC
My guess would be you were calling g_utf8_validate without including the right
header with a prototype.  Without a prototype, -1 will be passed as
0xffffffffUL in the corresponding register, while -1L or with a prototype
which has long type for the parameter as -1L (== 0xffffffffffffffffL).


Note You need to log in before you can comment on or make changes to this bug.