Skip to content

Commit

Permalink
Fix overflow error.
Browse files Browse the repository at this point in the history
* java/graphql_clj/Parser.java (push): ensure capacity before pushing the value.
* test/graphql_clj/parser_test/query-overflow.expected.edn: new file.
* test/graphql_clj/parser_test/query-overflow.input: new file.
  • Loading branch information
Casey Marshall committed Jul 31, 2017
1 parent 74672bc commit 6f6f9ac
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 0 deletions.
1 change: 1 addition & 0 deletions java/graphql_clj/Parser.java
Expand Up @@ -121,6 +121,7 @@ private void ensureCapacity() {
private void push(Keyword key, Object value) {
ensureCapacity();
_stack[_stackTop++] = key;
ensureCapacity();
_stack[_stackTop++] = value;
}

Expand Down
308 changes: 308 additions & 0 deletions test/graphql_clj/parser_test/query-overflow.expected.edn
@@ -0,0 +1,308 @@
^{:start [1 1 0], :end [1 487 486]}
[^{:start [1 1 0], :end [1 487 486]}
{:tag :selection-set
:selection-set
[^{:start [1 3 2], :end [1 16 15]}
{:tag :selection-field
:name ^{:start [1 3 2], :end [1 4 3]} a
:selection-set
[^{:start [1 7 6], :end [1 8 7]}
{:tag :selection-field
:name ^{:start [1 7 6], :end [1 8 7]} b}
^{:start [1 10 9], :end [1 11 10]}
{:tag :selection-field
:name ^{:start [1 10 9], :end [1 11 10]} c}
^{:start [1 13 12], :end [1 14 13]}
{:tag :selection-field
:name ^{:start [1 13 12], :end [1 14 13]} d}]}
^{:start [1 18 17], :end [1 485 484]}
{:tag :selection-field
:name ^{:start [1 18 17], :end [1 19 18]} e
:selection-set
[^{:start [1 22 21], :end [1 482 481]}
{:tag :selection-field
:name ^{:start [1 22 21], :end [1 23 22]} f
:selection-set
[^{:start [1 26 25], :end [1 27 26]}
{:tag :selection-field
:name ^{:start [1 26 25], :end [1 27 26]} g}
^{:start [1 29 28], :end [1 30 29]}
{:tag :selection-field
:name ^{:start [1 29 28], :end [1 30 29]} h}
^{:start [1 32 31], :end [1 33 32]}
{:tag :selection-field
:name ^{:start [1 32 31], :end [1 33 32]} i}
^{:start [1 35 34], :end [1 51 50]}
{:tag :selection-field
:name ^{:start [1 35 34], :end [1 36 35]} j
:selection-set
[^{:start [1 39 38], :end [1 40 39]}
{:tag :selection-field
:name ^{:start [1 39 38], :end [1 40 39]} k}
^{:start [1 42 41], :end [1 49 48]}
{:tag :selection-field
:name ^{:start [1 42 41], :end [1 43 42]} l
:selection-set
[^{:start [1 46 45], :end [1 47 46]}
{:tag :selection-field
:name ^{:start [1 46 45], :end [1 47 46]} m}]}]}
^{:start [1 53 52], :end [1 93 92]}
{:tag :selection-field
:name ^{:start [1 53 52], :end [1 54 53]} n
:selection-set
[^{:start [1 57 56], :end [1 58 57]}
{:tag :selection-field
:name ^{:start [1 57 56], :end [1 58 57]} o}
^{:start [1 60 59], :end [1 67 66]}
{:tag :selection-field
:name ^{:start [1 60 59], :end [1 61 60]} p
:selection-set
[^{:start [1 64 63], :end [1 65 64]}
{:tag :selection-field
:name ^{:start [1 64 63], :end [1 65 64]} q}]}
^{:start [1 69 68], :end [1 79 78]}
{:tag :selection-field
:name ^{:start [1 69 68], :end [1 70 69]} r
:selection-set
[^{:start [1 73 72], :end [1 74 73]}
{:tag :selection-field
:name ^{:start [1 73 72], :end [1 74 73]} s}
^{:start [1 76 75], :end [1 77 76]}
{:tag :selection-field
:name ^{:start [1 76 75], :end [1 77 76]} t}]}
^{:start [1 81 80], :end [1 91 90]}
{:tag :selection-field
:name ^{:start [1 81 80], :end [1 82 81]} u
:selection-set
[^{:start [1 85 84], :end [1 86 85]}
{:tag :selection-field
:name ^{:start [1 85 84], :end [1 86 85]} v}
^{:start [1 88 87], :end [1 89 88]}
{:tag :selection-field
:name ^{:start [1 88 87], :end [1 89 88]} w}]}]}
^{:start [1 95 94], :end [1 479 478]}
{:tag :selection-field
:name ^{:start [1 95 94], :end [1 96 95]} x
:selection-set
[^{:start [1 99 98], :end [1 100 99]}
{:tag :selection-field
:name ^{:start [1 99 98], :end [1 100 99]} y}
^{:start [1 102 101], :end [1 103 102]}
{:tag :selection-field
:name ^{:start [1 102 101], :end [1 103 102]} z}
^{:start [1 105 104], :end [1 107 106]}
{:tag :selection-field
:name ^{:start [1 105 104], :end [1 107 106]} aa}
^{:start [1 109 108], :end [1 111 110]}
{:tag :selection-field
:name ^{:start [1 109 108], :end [1 111 110]} bb}
^{:start [1 113 112], :end [1 115 114]}
{:tag :selection-field
:name ^{:start [1 113 112], :end [1 115 114]} cc}
^{:start [1 117 116], :end [1 119 118]}
{:tag :selection-field
:name ^{:start [1 117 116], :end [1 119 118]} dd}
^{:start [1 121 120], :end [1 123 122]}
{:tag :selection-field
:name ^{:start [1 121 120], :end [1 123 122]} ee}
^{:start [1 125 124], :end [1 152 151]}
{:tag :selection-field
:name ^{:start [1 125 124], :end [1 127 126]} ff
:selection-set
[^{:start [1 129 128], :end [1 131 130]}
{:tag :selection-field
:name ^{:start [1 129 128], :end [1 131 130]} gg}
^{:start [1 133 132], :end [1 135 134]}
{:tag :selection-field
:name ^{:start [1 133 132], :end [1 135 134]} hh}
^{:start [1 137 136], :end [1 146 145]}
{:tag :selection-field
:name ^{:start [1 137 136], :end [1 139 138]} ii
:selection-set
[^{:start [1 142 141], :end [1 144 143]}
{:tag :selection-field
:name ^{:start [1 142 141], :end [1 144 143]} jj}]}
^{:start [1 148 147], :end [1 150 149]}
{:tag :selection-field
:name ^{:start [1 148 147], :end [1 150 149]} kk}]}
^{:start [1 154 153], :end [1 214 213]}
{:tag :selection-field
:name ^{:start [1 154 153], :end [1 156 155]} ll
:selection-set
[^{:start [1 159 158], :end [1 161 160]}
{:tag :selection-field
:name ^{:start [1 159 158], :end [1 161 160]} mm}
^{:start [1 163 162], :end [1 165 164]}
{:tag :selection-field
:name ^{:start [1 163 162], :end [1 165 164]} nn}
^{:start [1 167 166], :end [1 169 168]}
{:tag :selection-field
:name ^{:start [1 167 166], :end [1 169 168]} oo}
^{:start [1 171 170], :end [1 211 210]}
{:tag :selection-field
:name ^{:start [1 171 170], :end [1 173 172]} pp
:selection-set
[^{:start [1 176 175], :end [1 178 177]}
{:tag :selection-field
:name ^{:start [1 176 175], :end [1 178 177]} qq}
^{:start [1 180 179], :end [1 182 181]}
{:tag :selection-field
:name ^{:start [1 180 179], :end [1 182 181]} rr}
^{:start [1 184 183], :end [1 186 185]}
{:tag :selection-field
:name ^{:start [1 184 183], :end [1 186 185]} ss}
^{:start [1 188 187], :end [1 197 196]}
{:tag :selection-field
:name ^{:start [1 188 187], :end [1 190 189]} tt
:selection-set
[^{:start [1 193 192], :end [1 195 194]}
{:tag :selection-field
:name ^{:start [1 193 192], :end [1 195 194]} uu}]}
^{:start [1 199 198], :end [1 208 207]}
{:tag :selection-field
:name ^{:start [1 199 198], :end [1 201 200]} vv
:selection-set
[^{:start [1 204 203], :end [1 206 205]}
{:tag :selection-field
:name ^{:start [1 204 203], :end [1 206 205]} ww}]}]}]}
^{:start [1 216 215], :end [1 225 224]}
{:tag :selection-field
:name ^{:start [1 216 215], :end [1 218 217]} xx
:selection-set
[^{:start [1 221 220], :end [1 223 222]}
{:tag :selection-field
:name ^{:start [1 221 220], :end [1 223 222]} yy}]}
^{:start [1 227 226], :end [1 476 475]}
{:tag :selection-field
:name ^{:start [1 227 226], :end [1 229 228]} zz
:selection-set
[^{:start [1 232 231], :end [1 235 234]}
{:tag :selection-field
:name ^{:start [1 232 231], :end [1 235 234]} aaa}
^{:start [1 237 236], :end [1 240 239]}
{:tag :selection-field
:name ^{:start [1 237 236], :end [1 240 239]} bbb}
^{:start [1 242 241], :end [1 245 244]}
{:tag :selection-field
:name ^{:start [1 242 241], :end [1 245 244]} ccc}
^{:start [1 247 246], :end [1 250 249]}
{:tag :selection-field
:name ^{:start [1 247 246], :end [1 250 249]} ddd}
^{:start [1 252 251], :end [1 255 254]}
{:tag :selection-field
:name ^{:start [1 252 251], :end [1 255 254]} eee}
^{:start [1 257 256], :end [1 260 259]}
{:tag :selection-field
:name ^{:start [1 257 256], :end [1 260 259]} fff}
^{:start [1 262 261], :end [1 265 264]}
{:tag :selection-field
:name ^{:start [1 262 261], :end [1 265 264]} ggg}
^{:start [1 267 266], :end [1 270 269]}
{:tag :selection-field
:name ^{:start [1 267 266], :end [1 270 269]} hhh}
^{:start [1 272 271], :end [1 275 274]}
{:tag :selection-field
:name ^{:start [1 272 271], :end [1 275 274]} iii}
^{:start [1 277 276], :end [1 280 279]}
{:tag :selection-field
:name ^{:start [1 277 276], :end [1 280 279]} jjj}
^{:start [1 282 281], :end [1 285 284]}
{:tag :selection-field
:name ^{:start [1 282 281], :end [1 285 284]} kkk}
^{:start [1 287 286], :end [1 318 317]}
{:tag :selection-field
:name ^{:start [1 287 286], :end [1 290 289]} lll
:selection-set
[^{:start [1 293 292], :end [1 296 295]}
{:tag :selection-field
:name ^{:start [1 293 292], :end [1 296 295]} mmm}
^{:start [1 298 297], :end [1 301 300]}
{:tag :selection-field
:name ^{:start [1 298 297], :end [1 301 300]} nnn}
^{:start [1 303 302], :end [1 306 305]}
{:tag :selection-field
:name ^{:start [1 303 302], :end [1 306 305]} ooo}
^{:start [1 308 307], :end [1 311 310]}
{:tag :selection-field
:name ^{:start [1 308 307], :end [1 311 310]} ppp}
^{:start [1 313 312], :end [1 316 315]}
{:tag :selection-field
:name ^{:start [1 313 312], :end [1 316 315]} qqq}]}
^{:start [1 320 319], :end [1 403 402]}
{:tag :selection-field
:name ^{:start [1 320 319], :end [1 323 322]} rrr
:selection-set
[^{:start [1 326 325], :end [1 329 328]}
{:tag :selection-field
:name ^{:start [1 326 325], :end [1 329 328]} sss}
^{:start [1 331 330], :end [1 334 333]}
{:tag :selection-field
:name ^{:start [1 331 330], :end [1 334 333]} ttt}
^{:start [1 336 335], :end [1 339 338]}
{:tag :selection-field
:name ^{:start [1 336 335], :end [1 339 338]} uuu}
^{:start [1 341 340], :end [1 344 343]}
{:tag :selection-field
:name ^{:start [1 341 340], :end [1 344 343]} vvv}
^{:start [1 346 345], :end [1 349 348]}
{:tag :selection-field
:name ^{:start [1 346 345], :end [1 349 348]} www}
^{:start [1 351 350], :end [1 385 384]}
{:tag :selection-field
:name ^{:start [1 351 350], :end [1 354 353]} xxx
:selection-set
[^{:start [1 357 356], :end [1 360 359]}
{:tag :selection-field
:name ^{:start [1 357 356], :end [1 360 359]} yyy}
^{:start [1 362 361], :end [1 365 364]}
{:tag :selection-field
:name ^{:start [1 362 361], :end [1 365 364]} zzz}
^{:start [1 367 366], :end [1 371 370]}
{:tag :selection-field
:name ^{:start [1 367 366], :end [1 371 370]} aaaa}
^{:start [1 373 372], :end [1 377 376]}
{:tag :selection-field
:name ^{:start [1 373 372], :end [1 377 376]} bbbb}
^{:start [1 379 378], :end [1 383 382]}
{:tag :selection-field
:name ^{:start [1 379 378], :end [1 383 382]} cccc}]}
^{:start [1 387 386], :end [1 400 399]}
{:tag :selection-field
:name ^{:start [1 387 386], :end [1 391 390]} dddd
:selection-set
[^{:start [1 394 393], :end [1 398 397]}
{:tag :selection-field
:name ^{:start [1 394 393], :end [1 398 397]} eeee}]}]}
^{:start [1 406 405], :end [1 419 418]}
{:tag :selection-field
:name ^{:start [1 406 405], :end [1 410 409]} ffff
:selection-set
[^{:start [1 413 412], :end [1 417 416]}
{:tag :selection-field
:name ^{:start [1 413 412], :end [1 417 416]} iiii}]}
^{:start [1 421 420], :end [1 473 472]}
{:tag :selection-field
:name ^{:start [1 421 420], :end [1 425 424]} jjjj
:selection-set
[^{:start [1 428 427], :end [1 432 431]}
{:tag :selection-field
:name ^{:start [1 428 427], :end [1 432 431]} kkkk}
^{:start [1 434 433], :end [1 438 437]}
{:tag :selection-field
:name ^{:start [1 434 433], :end [1 438 437]} llll}
^{:start [1 440 439], :end [1 444 443]}
{:tag :selection-field
:name ^{:start [1 440 439], :end [1 444 443]} mmmm}
^{:start [1 446 445], :end [1 450 449]}
{:tag :selection-field
:name ^{:start [1 446 445], :end [1 450 449]} nnnn}
^{:start [1 452 451], :end [1 471 470]}
{:tag :selection-field
:name ^{:start [1 452 451], :end [1 456 455]} oooo
:selection-set
[^{:start [1 459 458], :end [1 463 462]}
{:tag :selection-field
:name ^{:start [1 459 458], :end [1 463 462]} pppp}
^{:start [1 465 464], :end [1 469 468]}
{:tag :selection-field
:name ^{:start [1 465 464], :end [1 469 468]} qqqq}]}]}]}]}]}]}]}]
1 change: 1 addition & 0 deletions test/graphql_clj/parser_test/query-overflow.input
@@ -0,0 +1 @@
{ a { b, c, d }, e { f { g, h, i, j { k, l { m } }, n { o, p { q }, r { s, t }, u { v, w } }, x { y, z, aa, bb, cc, dd, ee, ff {gg, hh, ii { jj }, kk }, ll { mm, nn, oo, pp { qq, rr, ss, tt { uu }, vv { ww } } }, xx { yy }, zz { aaa, bbb, ccc, ddd, eee, fff, ggg, hhh, iii, jjj, kkk, lll { mmm, nnn, ooo, ppp, qqq }, rrr { sss, ttt, uuu, vvv, www, xxx { yyy, zzz, aaaa, bbbb, cccc }, dddd { eeee } } , ffff { iiii }, jjjj { kkkk, llll, mmmm, nnnn, oooo { pppp, qqqq } } } } } } }

0 comments on commit 6f6f9ac

Please sign in to comment.