www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11778] New: format for null does not verify fmt flags.

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778

           Summary: format for null does not verify fmt flags.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com


--- Comment #0 from monarchdodra gmail.com 2013-12-19 12:42:54 PST ---
Printing pointer types is supposed to only work with %X, %x or %s.

However, if the passed pointer is null, there is no actual fmt validation:

//----
import std.stdio;
void main()
{
    int* p;
    writefln(s, p);
    writefln(s, p + 1);
}
//----
null
std.format.FormatException std/format.d(2957): Expected one of %s, %x or %X for
pointer type.
//----

This can be an issue, as an invalid format flag may end up throwing depending
on the *value* passed (and not the type). The bug may only reveal itself
unexpectedly at a later date.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-12-20
06:39:59 PST ---
Where is 's' defined?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-12-20
06:41:48 PST ---
I guess this could be a test-case:

-----
import std.stdio;
void main()
{
    string s = "%d";
    int* p;
    writefln(s, p);  // does not throw
    writefln(s, p + 1);
}
-----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778



--- Comment #3 from monarchdodra gmail.com 2013-12-20 07:34:20 PST ---
(In reply to comment #1)
 Where is 's' defined?

Hum... I forgot to copy paste it. Much apologies. I had defined it as: enum s = "%d" (In reply to comment #2)
 I guess this could be a test-case:
 
 -----
 import std.stdio;
 void main()
 {
     string s = "%d";
     int* p;
     writefln(s, p);  // does not throw
     writefln(s, p + 1);
 }
 -----

Yes, exactly. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2014-04-03 04:51:24 PDT ---
https://github.com/D-Programming-Language/phobos/pull/2069

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778



--- Comment #5 from github-bugzilla puremagic.com 2014-04-03 08:01:42 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b32e4032c1adbdabd4cdcfe3599606d806762038
fix Issue 11778 - format for null does not verify fmt flags.

https://github.com/D-Programming-Language/phobos/commit/f8288c7ea321cfee94561f70a64fc01f81c7ae10
Merge pull request #2069 from 9rnsr/fix11778

Issue 11778 - format for null does not verify fmt flags.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 07 2014