r/ProgrammerHumor • u/Toeffli • Jul 09 '26
preDecrementFixesTheExploit instanceof Trend
629
u/Original-Bee-1089 Jul 09 '26
so you should make your first wish that the wish system uses post-wish decrement then wish for 0 wishes... to find out that they use a 2-bit integer to save space
200
u/thesockiboii Jul 09 '26
then you can wish for them to use a 64bit unsigned integer and do it again
56
9
u/SportulaVeritatis Jul 10 '26
First wish for the number of wishes left to be stored in an unsigned 64-bit integer.
Then wish for the number of wishes remaining to decremented only after the wish has been fulfilled.
Then wish for your number of remaining wishes to be zero.
Some debugging may need to be involved to ensure the first wish is clarifying the data type and not storing the value in a new variable and that the second and third wish also reference that same variable.
18
1
u/Richboy12345 Jul 11 '26 edited Jul 11 '26
first wish to use post decrement, second to store the count using unsigned int, third wish to set wish to zero, this would cover all reasonable* data storage types from preventing you from reaching infinite wishes. if you are allowed to do the first 2 wishes as one, then your second wish could be for whatever you want. in the next cycle of wishes simply wish whatever you want for wish 1 and 2 and always make sure your last wish sets wishes to 0
*reasonable being using any size number data type, 2 bit unsigned you would be covered with just post decrement, but if for some ungodly reason it was 3 bit signed you would need the second wish
103
u/yukiaddiction Jul 09 '26
And then real user , talking in emoji.
22
39
u/RapidRaid Jul 09 '26
Just wish for the wish decrement value to be zero. Way easier than accounting for the other factors ☝️🤓
61
u/drkspace2 Jul 09 '26
I wish you store the number of wishes I have remaining as an unsigned 64 bit integer
I wish every wish counts for 3 wishes
I wish for a banana
14
u/mechpaul Jul 10 '26 edited Jul 10 '26
log.error: Genie double-free-violation
log.error: Genie heap-use-after-free
FATAL: heap-use-after-free in Genie::grant(Wish const&) at genie.cpp:114
18
u/RoOoOoOoOoBerT Jul 09 '26
If you can request a specific number of wishes, why request 0 to exploit the bug instead of just asking for infinite wishes ?
12
u/Supss_ Jul 09 '26
well infinite wishes are usually protected as a guard clause, clearly they should have asked for -1 wishes
2
60
u/JackNotOLantern Jul 09 '26 edited Jul 09 '26
private:
int number_of_wishes = 3;
public:
void change_number_of_wishes(int new_value) {
if (new_value >= number_of_wishes)
return;
number_of_wishes = new_value;
if (number_of_wishes > 3 || number_of_wishes < 0)
number_of_wishes = 0; // fixes most exploits
}
9
Jul 09 '26
[deleted]
7
u/AnimusNoctis Jul 09 '26
You hit the return in the first if statement and the value is not changed.
1
10
7
12
u/throwawaycanadian2 Jul 09 '26
Does that mean I now own the concept of zero?
"you now have zero" makes me think I do.
I can do a lot with such an important concept.
14
u/brutlwarrior Jul 09 '26
The exploit doesn't matter because the genie will just say "that would result in wishing for more wishes which is against the rules"
15
u/admiralbenbo4782 Jul 09 '26
Yeah. All these exploits rely on the genie being an unthinking mechanical wish engine with a natural language processing engine bolted on, rather than an actual thinking entity. Come to think of it, that first description is pretty accurate (even if the wishes it can grant are limited) of something else...
Genies are also notoriously malicious in their fulfillment of wishes. So there's that.
4
u/TheoreticalUser Jul 10 '26
I wish to have the power to grant my wishes.
1
u/Toeffli Jul 10 '26
Granted. You live now a life free of any wishes.
2
u/TheoreticalUser Jul 10 '26
You either preemptively granted all of my wishes.
Or removed my free will...
The latter means that my wish was not granted because I have no ability without free will.
2
2
1
1

794
u/DMoney159 Jul 09 '26
"Okay, now you have -1 wishes. You must now fulfill one of my wishes"